Hi, I’m working on a project where we need to run TensorFlow inference on a Jetson Nano, using the C API. We were able to run the inference on a x86_64 host with no issues using the prebuilt binaries provided by TensorFlow ([url]https://www.tensorflow.org/install/lang_c[/url]), namely libtensorflow.so and libtensorflow_framework.so.
We want to do the same on the Jetson Nano but couldn’t find prebuilt binaries for aarch64 online.
We also manually tried to compile the C API libraries with Bazel with cross-compilation and on the Jetson Nano itself, but the task is not easy and we spent many days without success.
Since you probably already have the build pipeline set up to build python wheels, I wanted to ask if it was possible to also release the C API binaries (and maybe even C++ binaries).
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-5 g++-5 gcc-7 g++-7
#set comiler version to gcc-5 and g++-5
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
Attaching an external SSD to the Nano - I initially tried to empty out a 16 GB SD card running the Jetson Nano image but the Tensorflow build process takes way more space than you can free up on the SD card.
sudo mount /dev/sda1 /data/
Setting up swap memory on the external SSD
I added 8 GB swap space, moved all Tensorflow source and bazel output to external drive mounted to /data
Forcing bazel to write it’s output to the external SSD, using
export TEST_TMPDIR=/data/bazelcache
Using this Tensorflow build configuration
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
tensorflow-1.13.1$ ./configure
Please specify the location of python. [Default is /usr/bin/python]:
Found possible Python library paths:
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]
/usr/lib/python2.7/dist-packages
Do you wish to build TensorFlow with XLA JIT support? [Y/n]:
XLA JIT 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 ROCm support? [y/N]:
No ROCm 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. [Leave empty to default to CUDA 10.0]:
Please specify the location where CUDA 10.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]:
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:
Do you wish to build TensorFlow with TensorRT support? [y/N]:
No TensorRT support will be enabled for TensorFlow.
Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]:
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,7.0]: 5.3
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 -Wno-sign-compare]:
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:
Not configuring the WORKSPACE for Android builds.
And finally compile, excluding support for AWS (breaks the build) and NCCL (breaks and not needed).
Thank you so much J__T for the instructions on how to build the libraries, and especially for providing the pre-built binaries for TF 1.13.1!
Hopefully NVIDIA will provide future versions so that we don’t have to build them manually anymore, but this is a huge help for people who need a working API library and don’t have time/resources to build it themselves.