Skip to content

Commit 44c701a

Browse files
committed
Tensor Flow 1.3, L4T 28.1
1 parent ba7113e commit 44c701a

24 files changed

Lines changed: 308 additions & 334 deletions

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 Jetsonhacks
3+
Copyright (c) 2017 Jetsonhacks
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,116 @@
11
# installTensorFlowTX1
2-
December 28, 2016
2+
September 17, 2017
3+
JetsonHacks
34

4-
Last modified Jan 15, 2017
5+
Install TensorFlow v1.3 on NVIDIA Jetson TX1 Development Kit
56

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)
129
* CUDA 8.0
13-
* cuDNN 5.1.5
10+
* cuDNN 6.0
1411

1512
### 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.
1718

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:
1920

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.
2026
TensorFlow should be built in the following order:
2127

28+
## For Python 2.7
29+
2230
#### 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
2435

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.
2738

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
3040

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.
3343

3444
#### 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
3646

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.
3952

4053
#### buildTensorFlow.sh
4154
Builds TensorFlow.
4255

4356
#### 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.
4558

4659
#### 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
4865

49-
#### Test
50-
Run a simple TensorFlow example for the initial sanity check:
66+
$ pip3 install $HOME/<em>wheel file</em>
5167

52-
$ cd $HOME/tensorflow
5368

54-
$ time python tensorflow/models/image/mnist/convolutional.py
69+
### Notes
70+
This TensorFlow installation procedure was derived from these discussion threads:
5571

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
5792

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.
5993

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:
6294

63-
tensorflow/third_party/gpus/cuda_configure.bzl
95+
## License
96+
MIT License
6497

65-
Where the rule:
98+
Copyright (c) 2017 Jetsonhacks
6699

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:
68106

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.
70109

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.

buildTensorFlow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export TF_NEED_CUDA=1
77
export TF_CUDA_VERSION=8.0
88
export CUDA_TOOLKIT_PATH=/usr/local/cuda
9-
export TF_CUDNN_VERSION=5.1.5
9+
export TF_CUDNN_VERSION=6.0.21
1010
export CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu/
1111
export TF_CUDA_COMPUTE_CAPABILITIES=5.3
1212

cloneTensorFlow.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ INSTALL_DIR=$PWD
88
cd $HOME
99
git clone https://github.com/tensorflow/tensorflow.git
1010
cd tensorflow
11-
git checkout r0.11
11+
git checkout v1.3.0
1212
patch -p1 < $INSTALL_DIR/patches/tensorflow.patch
13-
patch -p1 < $INSTALL_DIR/patches/bazelzlib.patch
14-
patch -p1 < $INSTALL_DIR/patches/cudaConfigureBazel.patch
13+
# Patch up the Workspace.bzl for the Github Checksum issue
14+
patch -p1 < $INSTALL_DIR/patches/workspacebzl.patch
1515

1616

1717

createSwapfile.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
#NVIDIA Jetson TX1
3+
# Create a swap file and set up permissions
4+
# If a parameter is passed, it should be the place to create the swapfile
5+
SWAPDIRECTORY=$PWD
6+
SWAPSIZE=8
7+
AUTOMOUNT="N"
8+
function usage
9+
{
10+
echo "usage: createSwapFile [[[-d directory ] [-s size] -a] | [-h]]"
11+
echo "-d | --dir <directoryname> Directory to place swapfile"
12+
echo "-s | --size <gigabytes>"
13+
echo "-a | --auto Enable swap on boot in /etc/fstab "
14+
echo "-h | --help This message"
15+
}
16+
17+
while [ "$1" != "" ]; do
18+
case $1 in
19+
-d | --dir ) shift
20+
SWAPDIRECTORY=$1
21+
;;
22+
-s | --size ) shift
23+
SWAPSIZE=$1
24+
;;
25+
-a | --auto ) AUTOMOUNT="Y"
26+
;;
27+
-h | --help ) usage
28+
exit
29+
;;
30+
* ) usage
31+
exit 1
32+
esac
33+
shift
34+
done
35+
36+
echo "Creating Swapfile at: " $SWAPDIRECTORY
37+
echo "Swapfile Size: " $SWAPSIZE"G"
38+
echo "Automount: " $AUTOMOUNT
39+
40+
#Create a swapfile for Ubuntu at the current directory location
41+
sudo fallocate -l $SWAPSIZE"G" $SWAPDIRECTORY"/swapfile"
42+
cd $SWAPDIRECTORY
43+
#List out the file
44+
ls -lh swapfile
45+
# Change permissions so that only root can use it
46+
sudo chmod 600 swapfile
47+
#List out the file
48+
ls -lh swapfile
49+
#Set up the Linux swap area
50+
sudo mkswap swapfile
51+
#Now start using the swapfile
52+
sudo swapon swapfile
53+
#Show that it's now being used
54+
swapon -s
55+
56+
if [ "$AUTOMOUNT" = "Y" ]; then
57+
echo "Modifying /etc/fstab to enable on boot"
58+
SWAPLOCATION=$SWAPDIRECTORY"/swapfile"
59+
echo $SWAPLOCATION
60+
sudo sh -c 'echo "'$SWAPLOCATION' none swap sw 0 0" >> /etc/fstab'
61+
fi
62+

debug/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

debug/buildTensorFlow.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

installPrerequisites.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
# Install TensorFlow dependencies and prerequisites
44
# Install Java and other dependencies by apt-get
55
./scripts/installDependencies.sh
6-
# Build Protobuf
7-
# Two version are needed. v3.1.0 for grpc-java and v3.0.0-beta2 for Bazel
8-
./scripts/buildProtobuf.sh
9-
# Install grpc-java
10-
# Protobuf v3.1.0 should already have been built and installed before calling this script
11-
./scripts/buildGRPC.sh
12-
# Build Bazel 0.3.2
13-
./scripts/buildBazel.sh
6+
./scripts/installBazel.sh
147

158

installPrerequisitesPy3.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# NVIDIA Jetson TX1
3+
# Install TensorFlow dependencies and prerequisites
4+
# Install Java and other dependencies by apt-get
5+
./scripts/installDependenciesPy3.sh
6+
./scripts/installBazel.sh
7+
8+

packageTensorFlow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# NVIDIA Jetson TX1
33
cd $HOME/tensorflow
44
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
5-
mv /tmp/tensorflow_pkg/tensorflow-0.11.0-py2-none-any.whl $HOME/
5+
mv /tmp/tensorflow_pkg/tensorflow-*.whl $HOME/
66

0 commit comments

Comments
 (0)