|
1 | 1 | # installTensorFlowTX1 |
2 | | -December 28, 2016 |
| 2 | +September 17, 2017 |
| 3 | +JetsonHacks |
3 | 4 |
|
4 | | -Last modified Jan 15, 2017 |
| 5 | +Install TensorFlow v1.3 on NVIDIA Jetson TX1 Development Kit |
5 | 6 |
|
6 | | -Install TensorFlow r0.11 on NVIDIA Jetson TX1 Development Kit |
7 | | - |
8 | | -Full article and video on installation available at: http://www.jetsonhacks.com/2016/12/30/tensorflow-nvidia-jetson-tx1-development-kit/ |
9 | | - |
10 | | -Jetson TX1 is flashed with JetPack 2.3.1 which installs: |
11 | | -* L4T 24.2.1 an Ubuntu 16.04 64-bit variant (aarch64) |
| 7 | +Jetson TX1 is flashed with JetPack 3.1 which installs: |
| 8 | +* L4T 28.1 an Ubuntu 16.04 64-bit variant (aarch64) |
12 | 9 | * CUDA 8.0 |
13 | | -* cuDNN 5.1.5 |
| 10 | +* cuDNN 6.0 |
14 | 11 |
|
15 | 12 | ### Installation |
16 | | -Before installing TensorFlow, a swap file should be created (minimum of 8GB recommended). The Jetson TX1 does not have enough physical memory to compile TensorFlow. Also, if TensorFlow is being compiled on the built-in 16GB flash drive, a standard JetPack installation may consume too much room on the drive to successfully build TensorFlow. Extraneous files will need to be removed. Eliminating the .deb files in the home directory appears to be enough to allow TensorFlow to build. Successful builds tend to have more than 5.5GB free. Also, for a successful build it is recommended to set local lib using the included script setLocalLib.sh, as grpc-java in particular seems to run into issues if it /usr/local/lib is not in the path. |
| 13 | +Before installing TensorFlow, a swap file should be created (minimum of 8GB recommended). The Jetson TX1 does not have enough physical memory to compile TensorFlow. |
| 14 | + |
| 15 | +Note: L4T 28.1 does not have the swap file option selected in the stock kernel, so a custom kernel must be used with swap enabled. The option is 'Support for paging of anonymous memory (swap)'. The kernel configuration symbols are CONFIG_SWAP and SWAP. |
| 16 | + |
| 17 | +The eMMC does not have enough room for a properly sized swap file, the swap file should be located on a different device. A SATA drive is probably the fastest, followed by a USB drive then SD Card. The swap file is not needed after the build. Also, the swap file should be over 4GB. |
17 | 18 |
|
18 | | -Note: Most of this procedure was derived from the thread: https://github.com/tensorflow/tensorflow/issues/851 |
| 19 | +There is a convenience script for building a swap file. For example, to build a 8GB swapfile: |
19 | 20 |
|
| 21 | +$ ./createSwapfile.sh -d [file location] -s 8 |
| 22 | + |
| 23 | +After TensorFlow has finished building, the swap file is no longer needed and may be removed. |
| 24 | + |
| 25 | +These scripts support either builds for Python 2.7 or Python 3.5. |
20 | 26 | TensorFlow should be built in the following order: |
21 | 27 |
|
| 28 | +## For Python 2.7 |
| 29 | + |
22 | 30 | #### installPrerequisites.sh |
23 | | -Installs Java and other dependencies needed. Also builds: |
| 31 | +Installs Java and other dependencies needed. Also builds Bazel version 0.5.2. |
| 32 | + |
| 33 | +#### cloneTensorFlow.sh |
| 34 | +Git clones v1.3.0 from the TensorFlow repository and patches the source code for aarch64 |
24 | 35 |
|
25 | | -##### Protobuf |
26 | | -Two versions of protobuf are compiled. The first (v3.1.0) is needed to build grpc-java. This version ends up being installed in $HOME/lib and $HOME/bin. The second version (v3.0.0-beta-2) is used to build bazel |
| 36 | +#### setTensorFlowEV.sh |
| 37 | +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. |
27 | 38 |
|
28 | | -##### grpc-java |
29 | | -grpc-java v0.15.0 requires > v3.0.0-beta-3 of protobuf. A patch is applied for aarch64. |
| 39 | +## For Python 3.5 |
30 | 40 |
|
31 | | -##### Bazel |
32 | | -Builds version 0.3.2. Includes patches for compiling under aarch64. |
| 41 | +#### installPrerequisitesPy3.sh |
| 42 | +Installs Java and other dependencies needed. Also builds Bazel version 0.5.2. |
33 | 43 |
|
34 | 44 | #### cloneTensorFlow.sh |
35 | | -Git clones r0.11 from the TensorFlow repository and patches the source code for aarch64 |
| 45 | +Git clones v1.3.0 from the TensorFlow repository and patches the source code for aarch64 |
36 | 46 |
|
37 | | -#### setTensorFlowEV.sh |
38 | | -Sets up the TensorFlow environment variables. This script will ask for the default python library path. |
| 47 | +#### setTensorFlowEVPy3.sh |
| 48 | +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 3.5. |
| 49 | + |
| 50 | +## Build TensorFlow |
| 51 | +Once the prerequisites have been installed and the environment configured, it is time to build TensorFlow itself. |
39 | 52 |
|
40 | 53 | #### buildTensorFlow.sh |
41 | 54 | Builds TensorFlow. |
42 | 55 |
|
43 | 56 | #### packageTensorFlow.sh |
44 | | -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, tensorflow-0.11.0-py2-none-any.whl |
| 57 | +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. |
45 | 58 |
|
46 | 59 | #### Install wheel file |
47 | | -$ pip install $HOME/tensorflow-0.11.0-py2-none-any.whl |
| 60 | +For Python 2.X |
| 61 | + |
| 62 | +$ pip install $HOME/<em>wheel file</em> |
| 63 | + |
| 64 | +For Python 3.X |
48 | 65 |
|
49 | | -#### Test |
50 | | -Run a simple TensorFlow example for the initial sanity check: |
| 66 | +$ pip3 install $HOME/<em>wheel file</em> |
51 | 67 |
|
52 | | -$ cd $HOME/tensorflow |
53 | 68 |
|
54 | | -$ time python tensorflow/models/image/mnist/convolutional.py |
| 69 | +### Notes |
| 70 | +This TensorFlow installation procedure was derived from these discussion threads: |
55 | 71 |
|
56 | | -#### Build Issues |
| 72 | +<ul> |
| 73 | +<li>https://github.com/tensorflow/tensorflow/issues/851</li> |
| 74 | +<li>http://stackoverflow.com/questions/39783919/tensorflow-on-nvidia-tx1/</li> |
| 75 | +<li>https://devtalk.nvidia.com/default/topic/1000717/tensorflow-on-jetson-tx2/</li> |
| 76 | +<li>https://github.com/tensorflow/tensorflow/issues/9697</li> |
| 77 | +</ul> |
| 78 | + |
| 79 | +### Release Notes |
| 80 | +September 2017 |
| 81 | +* L4T 28.1 (JetPack 3.1) |
| 82 | +* TensorFlow 1.3 |
| 83 | +* CUDA 8.0 |
| 84 | +* cuDNN 6.0.12 |
| 85 | + |
| 86 | +December 2016 |
| 87 | +* Initial Release |
| 88 | +* L4T 24.2.1 |
| 89 | +* TensorFlow 0.11 |
| 90 | +* CUDA 8.0 |
| 91 | +* cuDNN 5.1.5 |
57 | 92 |
|
58 | | -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. |
59 | 93 |
|
60 | | -#### Notes |
61 | | -As of this writing (Jan 15, 2017) the TensorFlow repository has an issue which does not allow incremental compilation to work correctly. This is due to an issue in the file: |
62 | 94 |
|
63 | | -tensorflow/third_party/gpus/cuda_configure.bzl |
| 95 | +## License |
| 96 | +MIT License |
64 | 97 |
|
65 | | -Where the rule: |
| 98 | +Copyright (c) 2017 Jetsonhacks |
66 | 99 |
|
67 | | -cuda_configure = repository_rule( implementation = _cuda_autoconf_impl, local = True, ) |
| 100 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 101 | +of this software and associated documentation files (the "Software"), to deal |
| 102 | +in the Software without restriction, including without limitation the rights |
| 103 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 104 | +copies of the Software, and to permit persons to whom the Software is |
| 105 | +furnished to do so, subject to the following conditions: |
68 | 106 |
|
69 | | -forces Bazel to always rebuild the CUDA configuration, which in turn foobars the incremental build process. The cloneTensorFlow.sh script patches the file to remove the local = True statement. Additionally, buildTensorFlow.sh sets TensorFlow environment variables to reflect the CUDA structure of the Jetson TX1. |
| 107 | +The above copyright notice and this permission notice shall be included in all |
| 108 | +copies or substantial portions of the Software. |
70 | 109 |
|
71 | | -Since v0.11 was published, the location of the zlib library being used has moved. This is also taken into account by the cloneTensorFlow.sh script, which patches the library location. |
| 110 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 111 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 112 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 113 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 114 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 115 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 116 | +SOFTWARE. |
0 commit comments