12

How I built TensorFlow 1.8.0 on Jetson TX2

 3 years ago
source link: https://jkjung-avt.github.io/build-tensorflow-1.8.0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How I built TensorFlow 1.8.0 on Jetson TX2

Get bazel. I tested the latest version (0.17.1) of bazel and it was no good. So I downloaded and used bazel 0.15.2 instead.

$ cd ~/Downloads
$ wget https://github.com/bazelbuild/bazel/releases/download/0.15.2/bazel-0.15.2-dist.zip
$ mkdir -p ~/src
$ cd ~/src
$ unzip ~/Downloads/bazel-0.15.2-dist.zip -d bazel-0.15.2-dist
$ cd bazel-0.15.2-dist
$ ./compile.sh
$ sudo cp output/bazel /usr/local/bin
$ bazel help

Download tensorflow-1.8.0 source code.

$ cd ~/Downloads
$ wget https://github.com/tensorflow/tensorflow/archive/v1.8.0.tar.gz -O tensorflow-1.8.0.tar.gz
$ cd ~/src
$ tar xzvf ~/Downloads/tensorflow-1.8.0.tar.gz

Apply this patch to tensorflow-1.8.0 source code (~/src/tensorflow-1.8.0/third_party/png.BUILD).

diff --git a/third_party/png.BUILD b/third_party/png.BUILD
index 76ab32d..bc4551a 100644
--- a/third_party/png.BUILD
+++ b/third_party/png.BUILD
@@ -35,6 +35,7 @@ cc_library(
     ],
     includes = ["."],
     linkopts = ["-lm"],
+    copts = ["-DPNG_ARM_NEON_OPT=0"],
     visibility = ["//visibility:public"],
     deps = ["@zlib_archive//:zlib"],
 )

Configure tensorflow. Note that I’ve disabled cloud platform (GCP, AWS, etc.) support stuffs to save build time and make the pip package smaller. And do pay attention to the library paths for cuDNN and TensorRT (/usr/lib/aarch64-linux-gnu).

$ cd ~/src/tensorflow-1.8.0
$ ./configure
WARNING: ignoring http_proxy in environment.
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.15.2- (@non-git) installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3
   
   
Found possible Python library paths:
  /usr/local/lib/python3.5/dist-packages
  /usr/lib/python3/dist-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python3.5/dist-packages]
   
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: 
jemalloc as malloc support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
No Google Cloud Platform support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
No Hadoop File System support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n
No Amazon S3 File System support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: n
No Apache Kafka Platform support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with XLA JIT support? [y/N]: 
No XLA JIT support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with GDR support? [y/N]: 
No GDR support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with VERBS support? [y/N]: 
No VERBS support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: 
No OpenCL SYCL support will be enabled for TensorFlow.
   
Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.
   
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to default to CUDA 9.0]: 
   
   
Please specify the location where CUDA 9.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: 
   
   
Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]: 7.1.5
   
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:/usr/lib/aarch64-linux-gnu
   
   
Do you wish to build TensorFlow with TensorRT support? [y/N]: y
TensorRT support will be enabled for TensorFlow.
   
Please specify the location where TensorRT is installed. [Default is /usr/lib/aarch64-linux-gnu]:
   
   
Please specify the NCCL version you want to use. [Leave empty to default to NCCL 1.3]: 
   
   
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,5.2]6.2
   
   
Do you want to use clang as CUDA compiler? [y/N]: 
nvcc will be used as CUDA compiler.
   
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: 
   
   
Do you wish to build TensorFlow with MPI support? [y/N]: 
No MPI support will be enabled for TensorFlow.
   
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 
   
   
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: 
Not configuring the WORKSPACE for Android builds.
   
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
	--config=mkl         	# Build with MKL support.
	--config=monolithic  	# Config for mostly static monolithic build.
Configuration finished

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK