Nvidia Jetson Nano环境配置

DC Barrel jack[^1]

Place one of the jumpers on J48. J48 is located between the Barrel Jack connector and the Camera connector.

The Jetson has two power profiles, called modes. Mode 0 is 10W, Mode 1 is 5W. To set the mode to 5 Watt mode:

$ sudo nvpmodel -m 1

To set it back to 10 Watt mode:

$ sudo nvpmodel -m 0

The default image on the Jetson Nano is in 10 Watt mode. There’s another utility name jetson_clocks with which you may want to come familiar.

Write Image to the microSD Card[^2]

Download the Jetson Nano Developer Kit SD Card Image, and note where it was saved on the computer.

  1. Do not insert your microSD card yet.
  2. Download, install, and launch Etcher.
  3. Click “Select image” and choose the zipped image file downloaded earlier.
  4. Insert your microSD card(Click Ignore if your Mac shows windows).
  5. If you have no other external drives attached, Etcher will automatically select the microSD card as target device. Otherwise, click “Select drive” and choose the correct device.
  6. Click “Flash!” Your computer may prompt for your username and password before it allows Etcher to proceed. It will take Etcher about 10 minutes to write and validate the image if your microSD card is connected via USB3.
  7. After Etcher finishes(your Mac may let you know it doesn’t know how to read the SD Card), just click Eject and remove the microSD card.


sudo sh -c 'echo 30 > /sys/devices/pwm-fan/target_pwm'


Since memory (4GB) on the Jetson Nano is rather limited, I’d create and mount a swap file on the system. I referenced Create a Linux swap file for that. And I made a 8GB swap file on my Jetson Nano DevKit.

sudo fallocate -l 8G /mnt/8GB.swap
sudo chmod 600 /mnt/8GB.swap
sudo mkswap /mnt/8GB.swap
sudo swapon /mnt/8GB.swap

sudo cp /etc/fstab /etc/fstab.bak
echo '/mnt/8GB.swap none swap sw 0 0' | sudo tee -a /etc/fstab


sudo swapon -s

Filename Type Size Used Priority
/mnt/GB.swap file 8388604 0 -1



sudo gedit ~/.bashrc


export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda


source ~/.bashrc


nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep_30_21:09:22_CDT_2018
Cuda compilation tools, release 10.0, V10.0.166


sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list


deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
sudo apt-get update



sudo apt remove cmake

sudo make install
cmake --version
cmake version 3.14.5

CMake suite maintained and supported by Kitware (kitware.com/cmake).


sudo apt-get install libgtk-3-dev libavcodec-dev libavformat-dev python-dev python-numpy python-tk libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libswscale-dev libopenexr-dev libeigen3-dev libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libatlas-base-dev libqtgui4 python3-pyqt5 gfortran python3-dev qt5-default


sudo apt-get install python3-dev python3-pip python3-tk
sudo pip3 install numpy==1.16.4 matplotlib

sudo apt-get install python-dev python-pip python-tk
sudo pip2 install numpy==1.16.4 matplotlib

Jetson stats

sudo -H pip install jetson-stats

sudo jtop


OpenCV 3.4.2


sudo apt-get purge libopencv*


为了解决OpenCV3.4.2与CUDA10.0的冲突,下载NVIDIA VIDEO CODEC SDK,复制Video_Codec_SDK/include/下的nvcuvid.hcuviddec.h/usr/local/cuda/include/,修改opencv/modules/cudacodec/src/下的precomp.hppcuvid_video_source.hppframe_queue.hppvideo_parser.hppvideo_decoder.hpp

#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000 
#include <dynlink_nvcuvid.h>
#include <nvcuvid.h>


sudo gedit /usr/local/cuda/include/cuda_gl_interop.h

Here’s how the relevant lines (line #62~68) of cuda_gl_interop.h look like after the modification[^4][^5]:

//#if defined(__arm__) || defined(__aarch64__)
//#ifndef GL_VERSION
//#error Please include the appropriate gl headers before including cuda_gl_interop.h
#include <GL/gl.h>
cd /usr/lib/aarch64-linux-gnu/
sudo ln -sf libGL.so.1.0.0 libGL.so


mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_GTK_2_X=OFF -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D WITH_CUBLAS=ON -D CMAKE_CXX_FLAGS="-std=c++11" -D CUDA_NVCC_FLAGS="-std=c++11 --expt-relaxed-constexpr" -D WITH_NVCUVID=ON -D BUILD_opencv_cudacodec=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D ENABLE_NEON=ON -D WITH_LIBV4L=ON -D OPENCV_EXTRA_MODULES_PATH=/home/hanjie/Software/opencv-3.4.2/opencv_contrib/modules ..
-- General configuration for OpenCV 3.4.2 =====================================
-- Version control: unknown
-- Extra modules:
-- Location (extra): /home/hanjie/Software/opencv-3.4.2/opencv_contrib/modules
-- Version control (extra): 3.4.2
-- Platform:
-- Timestamp: 2019-07-09T09:09:02Z
-- Host: Linux 4.9.140-tegra aarch64
-- CMake: 3.14.5
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: Release
-- CPU/HW features:
-- Baseline: NEON FP16
-- required: NEON
-- disabled: VFPV3
-- C/C++:
-- Built as dynamic libs?: YES
-- C++11: YES
-- C++ Compiler: /usr/bin/c++ (ver 7.4.0)
-- C++ flags (Release): -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- ccache: NO
-- Precompiled headers: YES
-- Extra dependencies: dl m pthread rt /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
-- 3rdparty dependencies:
-- OpenCV modules:
-- To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: js world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj hdf java matlab ovis sfm ts viz
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: NO
-- GUI:
-- QT: YES (ver 5.9.5)
-- QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
-- GTK+: NO
-- OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
-- VTK support: NO
-- Media I/O:
-- ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
-- TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: /usr/lib/aarch64-linux-gnu/libImath.so /usr/lib/aarch64-linux-gnu/libIlmImf.so /usr/lib/aarch64-linux-gnu/libIex.so /usr/lib/aarch64-linux-gnu/libHalf.so /usr/lib/aarch64-linux-gnu/libIlmThread.so (ver 2.2.0)
-- Video I/O:
-- DC1394: YES (ver 2.2.5)
-- avcodec: YES (ver 57.107.100)
-- avformat: YES (ver 57.83.100)
-- avutil: YES (ver 55.78.100)
-- swscale: YES (ver 4.8.100)
-- avresample: NO
-- GStreamer:
-- base: YES (ver 1.14.1)
-- video: YES (ver 1.14.1)
-- app: YES (ver 1.14.1)
-- riff: YES (ver 1.14.1)
-- pbutils: YES (ver 1.14.1)
-- libv4l/libv4l2: 1.14.2 / 1.14.2
-- v4l/v4l2: linux/videodev2.h
-- gPhoto2: NO
-- Parallel framework: TBB (ver 2017.0 interface 9107)
-- Trace: YES (built-in)
-- Other third-party libraries:
-- Lapack: NO
-- Eigen: YES (ver 3.3.4)
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
-- NVIDIA GPU arch: 53
-- NVIDIA PTX archs:
-- OpenCL: YES (no extra features)
-- Include path: /home/hanjie/Software/opencv-3.4.2/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.15)
-- Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
-- numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.15.0)
-- packages path: lib/python2.7/dist-packages
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.6.8)
-- Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.8)
-- numpy: /usr/local/lib/python3.6/dist-packages/numpy/core/include (ver 1.15.0)
-- packages path: lib/python3.6/dist-packages
-- Python (for build): /usr/bin/python2.7
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
-- Matlab: NO
-- Install to: /usr/local
-- -----------------------------------------------------------------

make -j4
sudo make install

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig


sudo apt-get install autoconf automake libtool curl make g++ unzip

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.6.0.1
git submodule update --init --recursive

make -j4
make check -j4
sudo make install -j4
sudo ldconfig # refresh shared library cache.
protoc --version
libprotoc 3.6.0
sudo pip3 uninstall protobuf
cd protobuf/python
python3 setup.py build
python3 setup.py test
sudo python3 setup.py install


sudo apt-get install libhdf5-serial-dev hdf5-tools

# system-wide install
sudo pip3 install -U virtualenv

# Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
virtualenv --system-site-packages -p python3 ./deeplearning

# Activate the virtual environment using a shell-specific command:
source ./deeplearning/bin/activate

python3 -m pip install --upgrade pip
pip list
Package                       Version      
----------------------------- -------------
apt-clone 0.2.1
apturl 0.5.2
asn1crypto 0.24.0
beautifulsoup4 4.6.0
blinker 1.4
Brlapi 0.6.6
certifi 2018.1.18
chardet 3.0.4
cryptography 2.1.4
cupshelpers 1.0
cycler 0.10.0
defer 1.0.6
distro-info 0.18
feedparser 5.2.1
html5lib 0.999999999
httplib2 0.9.2
idna 2.6
keyring 10.6.0
keyrings.alt 3.0
kiwisolver 1.1.0
language-selector 0.1
launchpadlib 1.10.6
lazr.restfulclient 0.13.5
lazr.uri 1.0.3
louis 3.5.0
lxml 4.2.1
macaroonbakery 1.1.3
Mako 1.0.7
MarkupSafe 1.0
matplotlib 3.1.1
numpy 1.15.0
oauth 1.0.1
oauthlib 2.0.6
PAM 0.4.2
pip 19.1.1
protobuf 3.0.0
pycairo 1.16.2
pycrypto 2.6.1
pycups 1.9.73
pygobject 3.26.1
PyICU 1.9.8
PyJWT 1.5.3
pymacaroons 0.13.0
PyNaCl 1.1.2
pyparsing 2.4.0
pyRFC3339 1.0
python-apt 1.6.3+ubuntu1
python-dateutil 2.8.0
python-debian 0.1.32
pytz 2018.3
pyxdg 0.25
PyYAML 3.12
requests 2.18.4
requests-unixsocket 0.1.5
SecretStorage 2.3.1
setuptools 41.0.1
simplejson 3.13.2
six 1.11.0
ssh-import-id 5.7
system-service 0.3
systemd-python 234
ubuntu-drivers-common 0.0.0
unattended-upgrades 0.1
unity-scope-calculator 0.1
unity-scope-chromiumbookmarks 0.1
unity-scope-colourlovers 0.1
unity-scope-devhelp 0.1
unity-scope-firefoxbookmarks 0.1
unity-scope-manpages 0.1
unity-scope-openclipart 0.1
unity-scope-texdoc 0.1
unity-scope-tomboy 0.1
unity-scope-virtualbox 0.1
unity-scope-yelp 0.1
unity-scope-zotero 0.1
urllib3 1.22
virtualenv 16.6.1
wadllib 1.3.2
webencodings 0.5
wheel 0.33.4
xkit 0.0.0
zope.interface 4.3.2
pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3


# Python
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

config = tf.ConfigProto(allow_soft_placement=True)

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)

config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

hello = tf.constant('Hello, TensorFlow!')
Hello, TensorFlow!

And to exit virtualenv later:

deactivate  # don't exit until you're done using TensorFlow

Python Packages

sudo pip3 install cython
sudo pip3 install scipy sklearn pandas scikit-image


sudo apt-get install libhdf5-serial-dev libleveldb-dev libprotobuf-dev libsnappy-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev libatlas-base-dev libblas-dev libatlas-base-dev

sudo apt-get install --no-install-recommends libboost-all-dev
git clone https://github.com/BVLC/caffe.git

cd caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config






INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial

# PYTHON_INCLUDE := /usr/include/python2.7 \
# /usr/lib/python2.7/dist-packages/numpy/core/include

# Uncomment to use Python 3 (default is Python 2)
PYTHON_LIBRARIES := boost_python-py36 python3.6m
PYTHON_INCLUDE := /usr/include/python3.6m \

CUDA_ARCH := -gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_53,code=compute_53


LIBRARIES += glog gflags protobuf boost_system boost_filesystem m
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
make -j4
make -j4 test


make runtest -j4
make pycaffe
import sys
import caffe

or sudo gedit ~/.bashrc添加:

export PYTHONPATH=path_to/caffe/python:$PYTHONPATH
source ~/.bashrc


sudo apt-get install zlib1g-dev unzip openjdk-8-jdk

wget https://github.com/bazelbuild/bazel/releases/download/0.18.0/bazel-0.18.0-dist.zip
unzip bazel-0.18.0-dist.zip -d bazel-0.18.0
cd bazel-0.18.0

sudo cp output/bazel /usr/local/bin
bazel help

bazel version
Build label: 0.18.0- (@non-git)
Build target: bazel-out/aarch64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sat Jul 13 12:03:24 2019 (1563019404)
Build timestamp: 1563019404
Build timestamp as int: 1563019404


sudo rm -fr ~/.bazel ~/.bazelrc
sudo rm -fr ~/.cache/bazel
sudo rm /usr/local/bin/bazel /etc/bazelrc /usr/local/lib/bazel -fr

TensorFlow C++[^6]

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout v1.12.0

wget https://gist.githubusercontent.com/sdeoras/533708a95a3de5ff6de1c6b018cabf6d/raw/d0ff1fdcabb99aac3dce02f020cad0e5e78a8a56/tf_jetson_nano_build_112.diff

git apply tf_jetson_nano_build_112.diff

WARNING: ignoring LD_PRELOAD in environment.
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.18.0- (@non-git) installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3

Found possible Python library paths:
Please input the desired Python library path to use. Default is [/home/hanjie/Software/caffe/python]
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: n
No XLA JIT support will be enabled for TensorFlow.

Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.

Do you wish to build TensorFlow with ROCm support? [y/N]: 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 9.0]: 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]: 7.3.1

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]:/usr/src/tensorrt

Please specify the NCCL version you want to use. If NCCL 2.2 is not installed, then you can use version 1.3 that can be fetched automatically but it may have worse performance with multiple GPUs. [Default is 2.2]: 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,7.0]: 5.3

Do you want to use clang as CUDA compiler? [y/N]: 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]: 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]: 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.
--config=gdr # Build with GDR support.
--config=verbs # Build with libverbs support.
--config=ngraph # Build with Intel nGraph support.
Preconfigured Bazel build configs to DISABLE default on features:
--config=noaws # Disable AWS S3 filesystem support.
--config=nogcp # Disable GCP support.
--config=nohdfs # Disable HDFS support.
--config=noignite # Disable Apacha Ignite support.
--config=nokafka # Disable Apache Kafka support.
Configuration finished
bazel build -c opt --local_resources 5000,1.0,1.0 --verbose_failures --config=opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --copt="-DPNG_ARM_NEON_OPT=0" --config=noaws //tensorflow:libtensorflow_cc.so

bazel build -c opt --local_resources 5000,1.0,1.0 --verbose_failures --config=opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --config=cuda --copt=-DPNG_ARM_NEON_OPT=0 //tensorflow:libtensorflow_framework.so

sudo mkdir -p /usr/local/include/tf/tensorflow

sudo ln -s abs_path_to_tensorflow/bazel-genfiles/ /usr/local/include/tf
sudo ln -s abs_path_to_tensorflow/tensorflow/cc /usr/local/include/tf/tensorflow
sudo ln -s abs_path_to_tensorflow/tensorflow/core /usr/local/include/tf/tensorflow
sudo ln -s abs_path_to_tensorflow/third_party /usr/local/include/tf
sudo ln -s abs_path_to_tensorflow/bazel-bin/tensorflow/libtensorflow_cc.so /usr/local/lib
sudo ln -s abs_path_to_tensorflow/bazel-bin/tensorflow/libtensorflow_framework.so /usr/local/lib
git clone https://github.com/abseil/abseil-cpp.git
sudo ln -s abs_path_to_abseil-cpp/absl /usr/local/include/tf/third_party