Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jetsonhacks committed Mar 30, 2017
1 parent a36513d commit 4024aa6
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# installTensorFlowTX2
Install TensorFlow on the NVIDIA Jetson TX2 Development Kit

Work in progress

16 changes: 16 additions & 0 deletions buildTensorFlow.sh
Original file line number Diff line number Diff line change
@@ -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

16 changes: 16 additions & 0 deletions cloneTensorFlow.sh
Original file line number Diff line number Diff line change
@@ -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




8 changes: 8 additions & 0 deletions installPrerequisites.sh
Original file line number Diff line number Diff line change
@@ -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


6 changes: 6 additions & 0 deletions packageTensorFlow.sh
Original file line number Diff line number Diff line change
@@ -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/

13 changes: 13 additions & 0 deletions patches/bazel.patch
Original file line number Diff line number Diff line change
@@ -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.<String>of());

16 changes: 16 additions & 0 deletions patches/tensorflow.patch
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions scripts/installBazel.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions scripts/installDependencies.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions setLocalLib.sh
Original file line number Diff line number Diff line change
@@ -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



40 changes: 40 additions & 0 deletions setTensorFlowEV.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4024aa6

Please sign in to comment.