From 258229f53bc2922bb4adfbf7a6531ca53cfde69c Mon Sep 17 00:00:00 2001 From: jetsonhacks Date: Sat, 1 Apr 2017 17:42:34 -0700 Subject: [PATCH] Update patches and README --- README.md | 49 ++++++++++++++++++++++++++++-- patches/tensorflow.patch | 65 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index edcc25b..5fdbf74 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,50 @@ # installTensorFlowTX2 -Install TensorFlow on the NVIDIA Jetson TX2 Development Kit +April 1, 2017 +Install TensorFlow v1.0.1 on NVIDIA Jetson TX2 Development Kit -Work in progress +Jetson TX2 is flashed with JetPack 3.0 which installs: +* L4T 27.1 an Ubuntu 16.04 64-bit variant (aarch64) +* CUDA 8.0 +* cuDNN 5.1.10 + +### Installation +Before installing TensorFlow, a swap file should be created (minimum of 8GB recommended). The Jetson TX2 does not have enough physical memory to compile TensorFlow. The swap file may be located on the internal eMMC, and may be removed after the build. + +Note: This procedure was derived from these discussion threads: + + + +TensorFlow should be built in the following order: + +#### installPrerequisites.sh +Installs Java and other dependencies needed. Also builds: + +##### Bazel +Builds version 0.4.5. Includes patches for compiling under aarch64. + +#### cloneTensorFlow.sh +Git clones v1.0.1 from the TensorFlow repository and patches the source code for aarch64 + +#### setTensorFlowEV.sh +Sets up the TensorFlow environment variables. This script will ask for the default python library path. There are many settings to chose from, the script picks the usual suspects. Uses python 2.7. + +#### buildTensorFlow.sh +Builds TensorFlow. + +#### packageTensorFlow.sh +Once TensorFlow has finished building, this script may be used to create a 'wheel' file, a package for installing with Python. The wheel file will be in the $HOME directory. + +#### Install wheel file +$ pip install $HOME/wheel file + + +#### Build Issues + +For various reasons, the build may fail. The 'debug' folder contains a version of the buildTensorFlow.sh script which is more verbose in the way that it describes both what it is doing and errors it encounters. See the debug directory for more details. + +#### Notes diff --git a/patches/tensorflow.patch b/patches/tensorflow.patch index a83e4fd..8747b84 100644 --- a/patches/tensorflow.patch +++ b/patches/tensorflow.patch @@ -1,7 +1,66 @@ -diff --git tensorflow/stream_executor/cuda/cuda_gpu_executor.cc tensorflow/stream_executor/cuda/cuda_gpu_executor.cc +diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD +index 2e04827..9d81923 100644 +--- a/tensorflow/core/kernels/BUILD ++++ b/tensorflow/core/kernels/BUILD +@@ -1184,7 +1184,7 @@ tf_kernel_libraries( + "segment_reduction_ops", + "scan_ops", + "sequence_ops", +- "sparse_matmul_op", ++ #DC "sparse_matmul_op", + ], + deps = [ + ":bounds_check", +diff --git a/tensorflow/core/kernels/cwise_op_gpu_select.cu.cc b/tensorflow/core/kernels/cwise_op_gpu_select.cu.cc +index 02058a8..880a0c3 100644 +--- a/tensorflow/core/kernels/cwise_op_gpu_select.cu.cc ++++ b/tensorflow/core/kernels/cwise_op_gpu_select.cu.cc +@@ -43,8 +43,14 @@ struct BatchSelectFunctor { + const int all_but_batch = then_flat_outer_dims.dimension(1); + + #if !defined(EIGEN_HAS_INDEX_LIST) +- Eigen::array broadcast_dims{{ 1, all_but_batch }}; +- Eigen::Tensor::Dimensions reshape_dims{{ batch, 1 }}; ++ // Eigen::array broadcast_dims{{ 1, all_but_batch }}; ++ Eigen::array broadcast_dims; ++ broadcast_dims[0] = 1; ++ broadcast_dims[1] = all_but_batch; ++ // Eigen::Tensor::Dimensions reshape_dims{{ batch, 1 }}; ++ Eigen::Tensor::Dimensions reshape_dims; ++ reshape_dims[0] = batch; ++ reshape_dims[1] = 1; + #else + Eigen::IndexList, int> broadcast_dims; + broadcast_dims.set(1, all_but_batch); +diff --git a/tensorflow/core/kernels/sparse_tensor_dense_matmul_op_gpu.cu.cc b/tensorflow/core/kernels/sparse_tensor_dense_matmul_op_gpu.cu.cc +index a177696..28d2f59 100644 +--- a/tensorflow/core/kernels/sparse_tensor_dense_matmul_op_gpu.cu.cc ++++ b/tensorflow/core/kernels/sparse_tensor_dense_matmul_op_gpu.cu.cc +@@ -104,9 +104,17 @@ struct SparseTensorDenseMatMulFunctor { + int n = (ADJ_B) ? b.dimension(0) : b.dimension(1); + + #if !defined(EIGEN_HAS_INDEX_LIST) +- Eigen::Tensor::Dimensions matrix_1_by_nnz{{ 1, nnz }}; +- Eigen::array n_by_1{{ n, 1 }}; +- Eigen::array reduce_on_rows{{ 0 }}; ++ // Eigen::Tensor::Dimensions matrix_1_by_nnz{{ 1, nnz }}; ++ Eigen::Tensor::Dimensions matrix_1_by_nnz; ++ matrix_1_by_nnz[0] = 1; ++ matrix_1_by_nnz[1] = nnz; ++ // Eigen::array n_by_1{{ n, 1 }}; ++ Eigen::array n_by_1; ++ n_by_1[0] = n; ++ n_by_1[1] = 1; ++ // Eigen::array reduce_on_rows{{ 0 }}; ++ Eigen::array reduce_on_rows; ++ reduce_on_rows[0]= 0; + #else + Eigen::IndexList, int> matrix_1_by_nnz; + matrix_1_by_nnz.set(1, nnz); +diff --git a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc b/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 +--- a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc ++++ b/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.