From fe59bd93af2e45b9d673e00c1fb41151e9bd298c Mon Sep 17 00:00:00 2001 From: Q-engineering Date: Sat, 20 Mar 2021 12:24:21 +0100 Subject: [PATCH 1/4] Modified for RPi 64 OS + Jetson Nano Add configuration for Raspberry Pi 64-bit OS and Jetson Nano. The Nano does not know TF_NEED_CUDA, nor TF_CUDA_VERSION (= JETSON_CUDA). Simplest solution is an extra branch. --- configure.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/configure.py b/configure.py index 6db9998e3b..a34c7d3f84 100644 --- a/configure.py +++ b/configure.py @@ -51,6 +51,11 @@ def is_linux(): def is_raspi_arm(): return os.uname()[4] == "armv7l" +def is_aarch64(): + return os.uname()[4] == "aarch64" + +def is_nano(): + return os.uname()[1] == "nano" def get_tf_header_dir(): import tensorflow as tf @@ -68,7 +73,7 @@ def get_tf_shared_lib_dir(): if is_windows(): tf_shared_lib_dir = tf.sysconfig.get_compile_flags()[0][2:-7] + "python" return tf_shared_lib_dir.replace("\\", "/") - elif is_raspi_arm(): + elif is_raspi_arm() or is_aarch64(): return tf.sysconfig.get_compile_flags()[0][2:-7] + "python" else: return tf.sysconfig.get_link_flags()[0][2:] @@ -85,7 +90,7 @@ def get_shared_lib_name(): elif is_windows(): # Windows return "_pywrap_tensorflow_internal.lib" - elif is_raspi_arm(): + elif is_raspi_arm() or is_aarch64(): # The below command for linux would return an empty list return "_pywrap_tensorflow_internal.so" else: @@ -120,7 +125,10 @@ def create_build_configuration(): write("build:windows --cxxopt=/std:c++14") write("build:windows --host_cxxopt=/std:c++14") - if is_macos() or is_linux(): + if is_raspi_arm() or is_aarch64(): + write("build --cxxopt=-std=c++14") + write("build --host_cxxopt=-std=c++14") + elif is_macos() or is_linux(): write("build --copt=-mavx") write("build --cxxopt=-std=c++14") write("build --host_cxxopt=-std=c++14") @@ -128,6 +136,17 @@ def create_build_configuration(): if os.getenv("TF_NEED_CUDA", "0") == "1": print("> Building GPU & CPU ops") configure_cuda() + elif is_nano(): + print("> Building GPU & CPU ops") + write_action_env("TF_NEED_CUDA", "1") + write_action_env("CUDA_TOOLKIT_PATH", "/usr/local/cuda") + write_action_env("CUDNN_INSTALL_PATH", "/usr/lib/aarch64-linux-gnu"), + write_action_env("TF_CUDA_VERSION", "10") + write_action_env("TF_CUDNN_VERSION", "8") + write("test --config=cuda") + write("build --config=cuda") + write("build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true") + write("build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain") else: print("> Building only CPU ops") From 4f2c0c8bb70a53f41bab2543a285c2811c909511 Mon Sep 17 00:00:00 2001 From: Q-engineering Date: Sat, 20 Mar 2021 12:25:12 +0100 Subject: [PATCH 2/4] Python3 instead of Python --- build_deps/build_pip_pkg.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_deps/build_pip_pkg.sh b/build_deps/build_pip_pkg.sh index 6ba70c92ff..67c2233e14 100755 --- a/build_deps/build_pip_pkg.sh +++ b/build_deps/build_pip_pkg.sh @@ -82,9 +82,9 @@ function main() { if [[ -z ${NIGHTLY_FLAG} ]]; then # Windows has issues with locking library files for deletion so do not fail here - python ${BUILD_CMD} || true + python3 ${BUILD_CMD} || true else - python ${BUILD_CMD} ${NIGHTLY_FLAG} || true + python3 ${BUILD_CMD} ${NIGHTLY_FLAG} || true fi cp dist/*.whl "${DEST}" @@ -93,4 +93,4 @@ function main() { echo $(date) : "=== Output wheel file is in: ${DEST}" } -main "$@" \ No newline at end of file +main "$@" From 36a696d0bc4908dcba4521a61de93466a2f54e8f Mon Sep 17 00:00:00 2001 From: Q-engineering Date: Sat, 20 Mar 2021 12:43:18 +0100 Subject: [PATCH 3/4] Update configure.py --- configure.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.py b/configure.py index a34c7d3f84..ecc98b1b9b 100644 --- a/configure.py +++ b/configure.py @@ -51,12 +51,15 @@ def is_linux(): def is_raspi_arm(): return os.uname()[4] == "armv7l" + def is_aarch64(): return os.uname()[4] == "aarch64" + def is_nano(): return os.uname()[1] == "nano" + def get_tf_header_dir(): import tensorflow as tf From fa73c4569cf570e75b3cde44796155aba58e612a Mon Sep 17 00:00:00 2001 From: Q-engineering Date: Sat, 20 Mar 2021 12:54:27 +0100 Subject: [PATCH 4/4] Update configure.py --- configure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index ecc98b1b9b..e66f63fe4b 100644 --- a/configure.py +++ b/configure.py @@ -53,11 +53,11 @@ def is_raspi_arm(): def is_aarch64(): - return os.uname()[4] == "aarch64" + return os.uname()[4] == "aarch64" def is_nano(): - return os.uname()[1] == "nano" + return os.uname()[1] == "nano" def get_tf_header_dir():