diff --git a/README.md b/README.md index e059b58..edcc25b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # installTensorFlowTX2 Install TensorFlow on the NVIDIA Jetson TX2 Development Kit + +Work in progress + diff --git a/buildTensorFlow.sh b/buildTensorFlow.sh new file mode 100755 index 0000000..ec39453 --- /dev/null +++ b/buildTensorFlow.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +# TensorFlow Installation +# Export TensorFlow GPU environment variables +# WARNING This needs to match setTensorFlowEV.sh settings +export TF_NEED_CUDA=1 +export TF_CUDA_VERSION=8.0 +export CUDA_TOOLKIT_PATH=/usr/local/cuda +export TF_CUDNN_VERSION=5.1.10 +export CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu/ +export TF_CUDA_COMPUTE_CAPABILITIES=6.2 + +# Build Tensorflow +cd $HOME/tensorflow +bazel build -c opt --local_resources 3072,4.0,1.0 --verbose_failures --config=cuda //tensorflow/tools/pip_package:build_pip_package + diff --git a/cloneTensorFlow.sh b/cloneTensorFlow.sh new file mode 100755 index 0000000..4236970 --- /dev/null +++ b/cloneTensorFlow.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +# TensorFlow Installation +# Install Tensorflow repository then +# setup for compilation +# This does not build tensorflow +INSTALL_DIR=$PWD +cd $HOME +git clone https://github.com/tensorflow/tensorflow.git +cd tensorflow +git checkout v1.0.1 +patch -p1 < $INSTALL_DIR/patches/tensorflow.patch + + + + diff --git a/installPrerequisites.sh b/installPrerequisites.sh new file mode 100755 index 0000000..6ab0a3a --- /dev/null +++ b/installPrerequisites.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# NVIDIA Jetson TX2 +# Install TensorFlow dependencies and prerequisites +# Install Java and other dependencies by apt-get +./scripts/installDependencies.sh +./scripts/installBazel.sh + + diff --git a/packageTensorFlow.sh b/packageTensorFlow.sh new file mode 100755 index 0000000..159f1f7 --- /dev/null +++ b/packageTensorFlow.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +cd $HOME/tensorflow +bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg +mv /tmp/tensorflow_pkg/tensorflow-1.0.1-cp27-cp27mu-linux_aarch64.whl $HOME/ + diff --git a/patches/bazel.patch b/patches/bazel.patch new file mode 100644 index 0000000..4f7c6e5 --- /dev/null +++ b/patches/bazel.patch @@ -0,0 +1,13 @@ +diff --git src/main/java/com/google/devtools/build/lib/util/CPU.java src/main/java/com/google/devtools/build/lib/util/CPU.java +index 7a85c29..157119d 100644 +--- src/main/java/com/google/devtools/build/lib/util/CPU.java ++++ src/main/java/com/google/devtools/build/lib/util/CPU.java +@@ -25,7 +25,7 @@ public enum CPU { + X86_32("x86_32", ImmutableSet.of("i386", "i486", "i586", "i686", "i786", "x86")), + X86_64("x86_64", ImmutableSet.of("amd64", "x86_64", "x64")), + PPC("ppc", ImmutableSet.of("ppc", "ppc64", "ppc64le")), +- ARM("arm", ImmutableSet.of("arm", "armv7l")), ++ ARM("arm", ImmutableSet.of("aarch64", "arm", "armv7l" )), + S390X("s390x", ImmutableSet.of("s390x", "s390")), + UNKNOWN("unknown", ImmutableSet.of()); + diff --git a/patches/tensorflow.patch b/patches/tensorflow.patch new file mode 100644 index 0000000..40a154a --- /dev/null +++ b/patches/tensorflow.patch @@ -0,0 +1,16 @@ +diff --git tensorflow/stream_executor/cuda/cuda_gpu_executor.cc tensorflow/stream_executor/cuda/cuda_gpu_executor.cc +index b2da109..8ee1f3a 100644 +--- tensorflow/stream_executor/cuda/cuda_gpu_executor.cc ++++ tensorflow/stream_executor/cuda/cuda_gpu_executor.cc +@@ -870,7 +870,10 @@ CudaContext* CUDAExecutor::cuda_context() { return context_; } + // For anything more complicated/prod-focused than this, you'll likely want to + // turn to gsys' topology modeling. + static int TryToReadNumaNode(const string &pci_bus_id, int device_ordinal) { +-#if defined(__APPLE__) ++#ifdef __aarch64__ ++ // There is no numa_node on Jetson ARM64 ++ return 0; ++#elif defined(__APPLE__) + LOG(INFO) << "OS X does not support NUMA - returning NUMA node zero"; + return 0; + #elif defined(PLATFORM_WINDOWS) diff --git a/scripts/installBazel.sh b/scripts/installBazel.sh new file mode 100755 index 0000000..91e8f1f --- /dev/null +++ b/scripts/installBazel.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +# TensorFlow Installation +# Install Bazel +# We use the release distribution so that we don't have to build protobuf +# +INSTALL_DIR=$PWD +cd $HOME +wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip +unzip bazel-0.4.5-dist.zip -d bazel-0.4.5-dist +sudo chmod -R ug+rwx $HOME/bazel-0.4.5-dist +# git clone https://github.com/bazelbuild/bazel.git +cd bazel-0.4.5-dist +patch -p0 < $INSTALL_DIR/patches/bazel.patch +./compile.sh +sudo cp output/bazel /usr/local/bin diff --git a/scripts/installDependencies.sh b/scripts/installDependencies.sh new file mode 100755 index 0000000..4f01dd6 --- /dev/null +++ b/scripts/installDependencies.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +# Install TensorFlow dependencies +# Install Java +sudo add-apt-repository ppa:webupd8team/java +sudo apt-get update +sudo apt-get install oracle-java8-installer -y +# Install other dependencies +sudo apt-get install zip unzip autoconf automake libtool curl zlib1g-dev maven -y +sudo apt-get install python-numpy swig python-dev python-pip python-wheel -y diff --git a/setLocalLib.sh b/setLocalLib.sh new file mode 100755 index 0000000..c7b6af4 --- /dev/null +++ b/setLocalLib.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# NVIDIA Jetson TX1 +# TensorFlow Installation +# Useful setup command to set library path +sudo sh -c 'echo /usr/local/lib >> /etc/ld.so.conf' +sudo ldconfig + + + diff --git a/setTensorFlowEV.sh b/setTensorFlowEV.sh new file mode 100755 index 0000000..9b21dfa --- /dev/null +++ b/setTensorFlowEV.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# NVIDIA Jetson TX2 +# TensorFlow Installation +# Build TensorFlow + +cd $HOME/tensorflow +# TensorFlow couldn't find include file for some reason +# TensorFlow expects it in /usr/lib/aarch64-linux-gnu/include/cudnn.h +sudo mkdir /usr/lib/aarch64-linux-gnu/include/ +sudo cp /usr/include/cudnn.h /usr/lib/aarch64-linux-gnu/include/cudnn.h +# Setup the environment variables for configuration +# PYTHON Path is the default +default_python_bin_path=$(which python) +PYTHON_BIN_PATH=$default_python_bin_path +# No Google Cloud Platform support +TF_NEED_GCP=0 +# No Hadoop file system support +TF_NEED_HDFS=0 +# Use CUDA +TF_NEED_CUDA=1 +# Setup gcc ; just use the default +default_gcc_host_compiler_path=$(which gcc) +GCC_HOST_COMPILER_PATH=$default_gcc_host_compiler_path +# TF CUDA Version +TF_CUDA_VERSION=8.0 +# CUDA path +default_cuda_path=/usr/local/cuda +CUDA_TOOLKIT_PATH=$default_cuda_path +# cuDNN +TF_CUDNN_VERSION=5.1.10 +default_cudnn_path=/usr/lib/aarch64-linux-gnu +CUDNN_INSTALL_PATH=$default_cudnn_path +# CUDA compute capability +TF_CUDA_COMPUTE_CAPABILITIES=6.2 +CC_OPT_FLAGS=-march=native +TF_NEED_JEMALLOC=1 +TF_NEED_OPENCL=0 +TF_ENABLE_XLA=0 + +source ./configure