├── .gitignore ├── LICENSE ├── README.md ├── build_libtensorflow-2.3.0.sh ├── caffe └── Makefile.config.nano ├── fix_ssl_certificate.sh ├── install_basics.sh ├── install_bazel-0.15.2.sh ├── install_bazel-0.26.1.sh ├── install_bazel-3.1.0.sh ├── install_bazel-3.7.2.sh ├── install_opencv-3.4.6.sh ├── install_opencv-3.4.8.sh ├── install_opencv-4.5.5.sh ├── install_protobuf-3.6.1.sh ├── install_protobuf-3.8.0.sh ├── install_protobuf-3.9.2.sh ├── install_ssd-caffe.sh ├── install_tensorflow-1.12.2.sh ├── install_tensorflow-1.15.0.sh ├── install_tensorflow-2.0.0.sh ├── install_tensorflow-2.3.0.sh ├── opencv └── cuda_gl_interop.h.patch ├── tegra-cam.py.lnk └── tensorflow ├── mnist.py ├── tensorflow-1.12.2.patch ├── tensorflow-1.15.0.patch ├── tensorflow-2.0.0.patch └── tensorflow-2.3.0.patch /.gitignore: -------------------------------------------------------------------------------- 1 | tegra-cam.py 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 JK Jung 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jetson_nano 2 | 3 | This repository is a collection of scripts/programs I use to set up the software development environment on my Jetson Nano, TX2, and Xavier NX. 4 | 5 | To set Jetson Nano to 10W (MAXN) performance mode ([reference](https://devtalk.nvidia.com/default/topic/1050377/jetson-nano/deep-learning-inference-benchmarking-instructions/)), execute the following from a terminal: 6 | 7 | ```shell 8 | $ sudo nvpmodel -m 0 9 | $ sudo jetson_clocks 10 | ``` 11 | 12 | These are my blog posts related to the scripts in this repository: 13 | 14 | * [JetPack-4.6](https://jkjung-avt.github.io/jetpack-4.6/) 15 | * [JetPack-4.5](https://jkjung-avt.github.io/jetpack-4.5/) 16 | * [Setting up Jetson Xavier NX](https://jkjung-avt.github.io/setting-up-xavier-nx/) 17 | * [JetPack-4.4 for Jetson Nano](https://jkjung-avt.github.io/jetpack-4.4/) 18 | * [JetPack-4.3 for Jetson Nano](https://jkjung-avt.github.io/jetpack-4.3/) 19 | * [Building TensorFlow 2.0.0 on Jetson Nano](https://jkjung-avt.github.io/build-tensorflow-2.0.0/) 20 | * [Installing and Testing SSD Caffe on Jetson Nano](https://jkjung-avt.github.io/ssd-caffe-on-nano/) 21 | * [Building TensorFlow 1.12.2 on Jetson Nano](https://jkjung-avt.github.io/build-tensorflow-1.12.2/) 22 | * [Installing OpenCV 3.4.6 on Jetson Nano](https://jkjung-avt.github.io/opencv-on-nano/) 23 | * [Setting up Jetson Nano: The Basics](https://jkjung-avt.github.io/setting-up-nano/) 24 | 25 | And here is a list of TensorFlow versions with the corresponding bazel and protobuf versions: 26 | 27 | | tensorflow | bazel | protobuf | Tested on | 28 | |:----------:|:------:|:--------:|:-----------:| 29 | | 1.12.2 | 0.15.2 | 3.6.1 | JetPack-4.2 | 30 | | 1.15.0 | 0.26.1 | 3.8.0 | JetPack-4.3 | 31 | | 2.0.0 | 0.26.1 | 3.8.0 | JetPack-4.3 | 32 | | 2.3.0 | 3.1.0 | 3.8.0 | JetPack-4.4 | 33 | -------------------------------------------------------------------------------- /build_libtensorflow-2.3.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ ! $(head -1 /etc/nv_tegra_release) =~ R32.*4\.[34] ]] ; then 6 | echo "ERROR: not JetPack-4.4" 7 | exit 1 8 | fi 9 | 10 | case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in 11 | "33" ) # Nano and TX1 12 | cuda_compute=5.3 13 | ;; 14 | "24" ) # TX2 15 | cuda_compute=6.2 16 | ;; 17 | "25" ) # Xavier NX and AGX Xavier 18 | cuda_compute=7.2 19 | ;; 20 | * ) # default 21 | cuda_compute=5.3,6.2,7.2 22 | ;; 23 | esac 24 | 25 | script_path=$(realpath $0) 26 | patch_path=$(dirname $script_path)/tensorflow/tensorflow-2.3.0.patch 27 | trt_version=$(echo /usr/lib/aarch64-linux-gnu/libnvinfer.so.? | cut -d '.' -f 3) 28 | 29 | src_folder=${HOME}/src 30 | mkdir -p $src_folder 31 | 32 | if pip3 list | grep tensorflow > /dev/null; then 33 | echo "ERROR: tensorflow is installed already" 34 | exit 1 35 | fi 36 | 37 | if ! which bazel > /dev/null; then 38 | echo "ERROR: bazel has not been installled" 39 | exit 1 40 | fi 41 | 42 | echo "** Install requirements" 43 | sudo apt-get install -y libhdf5-serial-dev hdf5-tools 44 | sudo pip3 install -U pip six 'numpy<1.19.0' wheel setuptools mock 'future>=0.17.1' 'gast==0.3.3' typing_extensions h5py 45 | sudo pip3 install -U keras_applications --no-deps 46 | sudo pip3 install -U keras_preprocessing --no-deps 47 | 48 | export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH 49 | 50 | echo "** Download and patch tensorflow-2.3.0" 51 | pushd $src_folder 52 | if [ ! -f tensorflow-2.3.0.tar.gz ]; then 53 | wget https://github.com/tensorflow/tensorflow/archive/v2.3.0.tar.gz -O tensorflow-2.3.0.tar.gz 54 | fi 55 | tar xzvf tensorflow-2.3.0.tar.gz 56 | cd tensorflow-2.3.0 57 | 58 | patch -N -p1 < $patch_path && echo "tensorflow-2.3.0 source tree appears to be patched already. Continue..." 59 | 60 | echo "** Configure and build libtensorflow-2.3.0" 61 | export TMP=/tmp 62 | PYTHON_BIN_PATH=$(which python3) \ 63 | PYTHON_LIB_PATH=$(python3 -c 'import site; print(site.getsitepackages()[0])') \ 64 | TF_CUDA_COMPUTE_CAPABILITIES=${cuda_compute} \ 65 | TF_CUDA_VERSION=10.2 \ 66 | TF_CUDA_CLANG=0 \ 67 | TF_CUDNN_VERSION=8 \ 68 | TF_TENSORRT_VERSION=${trt_version} \ 69 | CUDA_TOOLKIT_PATH=/usr/local/cuda \ 70 | CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 71 | TENSORRT_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 72 | TF_NEED_IGNITE=0 \ 73 | TF_ENABLE_XLA=0 \ 74 | TF_NEED_OPENCL_SYCL=0 \ 75 | TF_NEED_COMPUTECPP=0 \ 76 | TF_NEED_ROCM=0 \ 77 | TF_NEED_CUDA=1 \ 78 | TF_NEED_TENSORRT=1 \ 79 | TF_NEED_OPENCL=0 \ 80 | TF_NEED_MPI=0 \ 81 | GCC_HOST_COMPILER_PATH=$(which gcc) \ 82 | CC_OPT_FLAGS="-march=native" \ 83 | TF_SET_ANDROID_WORKSPACE=0 \ 84 | ./configure 85 | 86 | bazel build --config=opt \ 87 | --config=v2 \ 88 | --config=cuda \ 89 | --config=noaws \ 90 | --local_cpu_resources=HOST_CPUS*0.25 \ 91 | --local_ram_resources=HOST_RAM*0.5 \ 92 | //tensorflow/tools/lib_package:libtensorflow 93 | 94 | echo "** Build libtensorflow-2.3.0 successfully" 95 | -------------------------------------------------------------------------------- /caffe/Makefile.config.nano: -------------------------------------------------------------------------------- 1 | ## Refer to http://caffe.berkeleyvision.org/installation.html 2 | # Contributions simplifying and improving our build system are welcome! 3 | 4 | # cuDNN acceleration switch (uncomment to build with cuDNN). 5 | USE_CUDNN := 1 6 | 7 | # CPU-only switch (uncomment to build without GPU support). 8 | # CPU_ONLY := 1 9 | 10 | # uncomment to disable IO dependencies and corresponding data layers 11 | # USE_OPENCV := 0 12 | # USE_LEVELDB := 0 13 | # USE_LMDB := 0 14 | 15 | # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary) 16 | # You should not set this flag if you will be reading LMDBs with any 17 | # possibility of simultaneous read and write 18 | # ALLOW_LMDB_NOLOCK := 1 19 | 20 | # Uncomment if you're using OpenCV 3 21 | OPENCV_VERSION := 3 22 | 23 | # To customize your choice of compiler, uncomment and set the following. 24 | # N.B. the default for Linux is g++ and the default for OSX is clang++ 25 | # CUSTOM_CXX := g++ 26 | 27 | # CUDA directory contains bin/ and lib/ directories that we need. 28 | CUDA_DIR := /usr/local/cuda 29 | # On Ubuntu 14.04, if cuda tools are installed via 30 | # "sudo apt-get install nvidia-cuda-toolkit" then use this instead: 31 | # CUDA_DIR := /usr 32 | 33 | # CUDA architecture setting: going with all of them. 34 | # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility. 35 | # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility. 36 | CUDA_ARCH := -gencode arch=compute_53,code=sm_53 \ 37 | -gencode arch=compute_62,code=sm_62 \ 38 | -gencode arch=compute_72,code=sm_72 \ 39 | -gencode arch=compute_72,code=compute_72 40 | 41 | # BLAS choice: 42 | # atlas for ATLAS (default) 43 | # mkl for MKL 44 | # open for OpenBlas 45 | BLAS := atlas 46 | # Custom (MKL/ATLAS/OpenBLAS) include and lib directories. 47 | # Leave commented to accept the defaults for your choice of BLAS 48 | # (which should work)! 49 | # BLAS_INCLUDE := /path/to/your/blas 50 | # BLAS_LIB := /path/to/your/blas 51 | 52 | # Homebrew puts openblas in a directory that is not on the standard search path 53 | # BLAS_INCLUDE := $(shell brew --prefix openblas)/include 54 | # BLAS_LIB := $(shell brew --prefix openblas)/lib 55 | 56 | # This is required only if you will compile the matlab interface. 57 | # MATLAB directory should contain the mex binary in /bin. 58 | # MATLAB_DIR := /usr/local 59 | # MATLAB_DIR := /Applications/MATLAB_R2012b.app 60 | 61 | # NOTE: this is required only if you will compile the python interface. 62 | # We need to be able to find Python.h and numpy/arrayobject.h. 63 | # PYTHON_INCLUDE := /usr/include/python2.7 \ 64 | # /usr/lib/python2.7/dist-packages/numpy/core/include 65 | # Anaconda Python distribution is quite popular. Include path: 66 | # Verify anaconda location, sometimes it's in root. 67 | # ANACONDA_HOME := $(HOME)/anaconda 68 | # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ 69 | # $(ANACONDA_HOME)/include/python2.7 \ 70 | # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include 71 | 72 | # Uncomment to use Python 3 (default is Python 2) 73 | PYTHON_LIBRARIES := boost_python-py36 python3.6m 74 | PYTHON_INCLUDE := /usr/include/python3.6m \ 75 | /usr/local/lib/python3.6/dist-packages/numpy/core/include 76 | 77 | # We need to be able to find libpythonX.X.so or .dylib. 78 | PYTHON_LIB := /usr/lib 79 | # PYTHON_LIB := $(ANACONDA_HOME)/lib 80 | 81 | # Homebrew installs numpy in a non standard path (keg only) 82 | # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include 83 | # PYTHON_LIB += $(shell brew --prefix numpy)/lib 84 | 85 | # Uncomment to support layers written in Python (will link against Python libs) 86 | WITH_PYTHON_LAYER := 1 87 | 88 | # Whatever else you find you need goes here. 89 | INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial 90 | LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial 91 | 92 | # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies 93 | # INCLUDE_DIRS += $(shell brew --prefix)/include 94 | # LIBRARY_DIRS += $(shell brew --prefix)/lib 95 | 96 | # NCCL acceleration switch (uncomment to build with NCCL) 97 | # https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0) 98 | # USE_NCCL := 1 99 | 100 | # Uncomment to use `pkg-config` to specify OpenCV library paths. 101 | # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) 102 | # USE_PKG_CONFIG := 1 103 | 104 | # N.B. both build and distribute dirs are cleared on `make clean` 105 | BUILD_DIR := build 106 | DISTRIBUTE_DIR := distribute 107 | 108 | # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171 109 | # DEBUG := 1 110 | 111 | # The ID of the GPU that 'make runtest' will use to run unit tests. 112 | TEST_GPUID := 0 113 | 114 | # enable pretty build (comment to see full commands) 115 | Q ?= @ 116 | 117 | #COMMON_FLAGS += -O3 -ffast-math -flto -march=armv8-a+crypto -mcpu=cortex-a57+crypto 118 | -------------------------------------------------------------------------------- /fix_ssl_certificate.sh: -------------------------------------------------------------------------------- 1 | # I found this fix from the following JetsonHacks' script 2 | # https://github.com/jetsonhacks/installROSTX1/blob/master/installROS.sh 3 | 4 | # This fixes the issue of wget failing with "ERROR: cannot verify XXXXX's certificate" 5 | sudo c_rehash /etc/ssl/certs 6 | -------------------------------------------------------------------------------- /install_basics.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if ! grep 'cuda/bin' ${HOME}/.bashrc > /dev/null ; then 6 | echo "** Add CUDA stuffs into ~/.bashrc" 7 | echo >> ${HOME}/.bashrc 8 | echo "export PATH=/usr/local/cuda/bin\${PATH:+:\${PATH}}" >> ${HOME}/.bashrc 9 | echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}}" >> ${HOME}/.bashrc 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /install_bazel-0.15.2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Reference: https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu 4 | 5 | set -e 6 | 7 | folder=${HOME}/src 8 | mkdir -p $folder 9 | 10 | echo "** Install requirements" 11 | sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip 12 | sudo apt-get install -y openjdk-8-jdk 13 | 14 | echo "** Download bazel-0.15.2 sources" 15 | cd $folder 16 | if [ ! -f bazel-0.15.2-dist.zip ]; then 17 | wget https://github.com/bazelbuild/bazel/releases/download/0.15.2/bazel-0.15.2-dist.zip 18 | fi 19 | 20 | echo "** Build and install bazel-0.15.2" 21 | unzip bazel-0.15.2-dist.zip -d bazel-0.15.2-dist 22 | cd bazel-0.15.2-dist 23 | ./compile.sh 24 | sudo cp output/bazel /usr/local/bin 25 | bazel help 26 | 27 | echo "** Build bazel-0.15.2 successfully" 28 | -------------------------------------------------------------------------------- /install_bazel-0.26.1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Reference: https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu 4 | 5 | set -e 6 | 7 | folder=${HOME}/src 8 | mkdir -p $folder 9 | 10 | echo "** Install requirements" 11 | sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip 12 | sudo apt-get install -y openjdk-8-jdk 13 | 14 | echo "** Download bazel-0.26.1 sources" 15 | cd $folder 16 | if [ ! -f bazel-0.26.1-dist.zip ]; then 17 | wget https://github.com/bazelbuild/bazel/releases/download/0.26.1/bazel-0.26.1-dist.zip 18 | fi 19 | 20 | echo "** Build and install bazel-0.26.1" 21 | unzip bazel-0.26.1-dist.zip -d bazel-0.26.1-dist 22 | cd bazel-0.26.1-dist 23 | EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh 24 | sudo cp output/bazel /usr/local/bin 25 | bazel help 26 | 27 | echo "** Build bazel-0.26.1 successfully" 28 | -------------------------------------------------------------------------------- /install_bazel-3.1.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Reference: https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu 4 | 5 | set -e 6 | 7 | folder=${HOME}/src 8 | mkdir -p $folder 9 | 10 | echo "** Install requirements" 11 | sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip 12 | sudo apt-get install -y openjdk-8-jdk 13 | 14 | echo "** Download bazel-3.1.0 sources" 15 | pushd $folder 16 | if [ ! -f bazel-3.1.0-dist.zip ]; then 17 | wget https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-dist.zip 18 | fi 19 | 20 | echo "** Build and install bazel-3.1.0" 21 | unzip bazel-3.1.0-dist.zip -d bazel-3.1.0-dist 22 | cd bazel-3.1.0-dist 23 | EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh 24 | 25 | mkdir -p ${HOME}/bin 26 | cp output/bazel ${HOME}/bin 27 | if [[ ${PATH} != *${HOME}/bin* ]]; then 28 | export PATH=${HOME}/bin:${PATH} 29 | fi 30 | bazel help 31 | 32 | popd 33 | 34 | echo "** Build bazel-3.1.0 successfully" 35 | -------------------------------------------------------------------------------- /install_bazel-3.7.2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Reference: https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu 4 | 5 | set -e 6 | 7 | version=3.7.2 8 | 9 | folder=${HOME}/src 10 | mkdir -p $folder 11 | 12 | echo "** Install requirements" 13 | sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip 14 | sudo apt-get install -y openjdk-8-jdk 15 | 16 | echo "** Download bazel-${version} sources" 17 | pushd $folder 18 | if [ ! -f bazel-${version}-dist.zip ]; then 19 | wget https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip 20 | fi 21 | 22 | echo "** Build and install bazel-${version}" 23 | unzip bazel-${version}-dist.zip -d bazel-${version}-dist 24 | cd bazel-${version}-dist 25 | EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh 26 | 27 | mkdir -p ${HOME}/bin 28 | cp output/bazel ${HOME}/bin 29 | if [[ ${PATH} != *${HOME}/bin* ]]; then 30 | export PATH=${HOME}/bin:${PATH} 31 | fi 32 | bazel help 33 | 34 | popd 35 | 36 | echo "** Build bazel-${version} successfully" 37 | -------------------------------------------------------------------------------- /install_opencv-3.4.6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # NVIDIA Corporation and its licensors retain all intellectual property 6 | # and proprietary rights in and to this software, related documentation 7 | # and any modifications thereto. Any use, reproduction, disclosure or 8 | # distribution of this software and related documentation without an express 9 | # license agreement from NVIDIA Corporation is strictly prohibited. 10 | # 11 | 12 | # The orginal script 'install_opencv4.0.0_Nano.sh' could be found here: 13 | # https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh 14 | # 15 | # I did some modification so that it installs opencv-3.4.6 instead. Refer 16 | # to my blog posts for more details. 17 | # 18 | # JK Jung, jkjung13@gmail.com 19 | 20 | set -e 21 | 22 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 23 | case ${chip_id} in 24 | "33" ) # Nano and TX1 25 | cuda_compute=5.3 26 | ;; 27 | "24" ) # TX2 28 | cuda_compute=6.2 29 | ;; 30 | "25" ) # AGX Xavier 31 | cuda_compute=7.2 32 | ;; 33 | * ) # default 34 | cuda_compute=5.3,6.2,7.2 35 | ;; 36 | esac 37 | 38 | py3_ver=$(python3 -c "import sys; print(sys.version_info[1])") 39 | 40 | folder=${HOME}/src 41 | mkdir -p $folder 42 | 43 | echo "** Purge old opencv installation" 44 | sudo apt-get purge -y libopencv* 45 | 46 | echo "** Install requirements" 47 | sudo apt-get update 48 | sudo apt-get install -y build-essential make cmake cmake-curses-gui git g++ pkg-config curl 49 | sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libeigen3-dev libglew-dev libgtk2.0-dev 50 | sudo apt-get install -y libtbb2 libtbb-dev libv4l-dev v4l-utils qv4l2 v4l2ucp 51 | sudo apt-get install -y libdc1394-22-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev 52 | # sudo apt-get install -y libjasper-dev 53 | sudo apt-get install -y libjpeg8-dev libjpeg-turbo8-dev libtiff-dev libpng-dev 54 | sudo apt-get install -y libxvidcore-dev libx264-dev libgtk-3-dev 55 | sudo apt-get install -y libatlas-base-dev libopenblas-dev liblapack-dev liblapacke-dev gfortran 56 | sudo apt-get install -y qt5-default 57 | 58 | sudo apt-get install -y python3-dev python3-testresources 59 | rm -f $folder/get-pip.py 60 | wget https://bootstrap.pypa.io/get-pip.py -O $folder/get-pip.py 61 | sudo python3 $folder/get-pip.py 62 | sudo pip3 install protobuf 63 | sudo pip3 install -U numpy matplotlib 64 | 65 | if [ ! -f /usr/local/cuda/include/cuda_gl_interop.h.bak ]; then 66 | sudo cp /usr/local/cuda/include/cuda_gl_interop.h /usr/local/cuda/include/cuda_gl_interop.h.bak 67 | fi 68 | sudo patch -N -r - /usr/local/cuda/include/cuda_gl_interop.h < opencv/cuda_gl_interop.h.patch && echo "** '/usr/local/cuda/include/cuda_gl_interop.h' appears to be patched already. Continue..." 69 | 70 | echo "** Download opencv-3.4.6" 71 | cd $folder 72 | if [ ! -f opencv-3.4.6.zip ]; then 73 | wget https://github.com/opencv/opencv/archive/3.4.6.zip -O opencv-3.4.6.zip 74 | fi 75 | if [ -d opencv-3.4.6 ]; then 76 | echo "** ERROR: opencv-3.4.6 directory already exists" 77 | exit 78 | fi 79 | unzip opencv-3.4.6.zip 80 | cd opencv-3.4.6/ 81 | 82 | echo "** Building opencv..." 83 | mkdir build 84 | cd build/ 85 | 86 | cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ 87 | -D WITH_CUDA=ON -D CUDA_ARCH_BIN=${cuda_compute} -D CUDA_ARCH_PTX="" \ 88 | -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON \ 89 | -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON \ 90 | -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON \ 91 | -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF \ 92 | -D WITH_QT=ON -D WITH_OPENGL=ON .. 93 | make -j$(nproc) 94 | sudo make install 95 | sudo ldconfig 96 | 97 | python3 -c 'import cv2; print("python3 cv2 version: %s" % cv2.__version__)' 98 | 99 | echo "** Install opencv-3.4.6 successfully" 100 | -------------------------------------------------------------------------------- /install_opencv-3.4.8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # NVIDIA Corporation and its licensors retain all intellectual property 6 | # and proprietary rights in and to this software, related documentation 7 | # and any modifications thereto. Any use, reproduction, disclosure or 8 | # distribution of this software and related documentation without an express 9 | # license agreement from NVIDIA Corporation is strictly prohibited. 10 | # 11 | 12 | # The orginal script 'install_opencv4.0.0_Nano.sh' could be found here: 13 | # https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh 14 | # 15 | # I did some modification so that it installs opencv-3.4.8 instead. Refer 16 | # to my blog posts for more details. 17 | # 18 | # JK Jung, jkjung13@gmail.com 19 | 20 | set -e 21 | 22 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 23 | case ${chip_id} in 24 | "33" ) # Nano and TX1 25 | cuda_compute=5.3 26 | ;; 27 | "24" ) # TX2 28 | cuda_compute=6.2 29 | ;; 30 | "25" ) # AGX Xavier 31 | cuda_compute=7.2 32 | ;; 33 | * ) # default 34 | cuda_compute=5.3,6.2,7.2 35 | ;; 36 | esac 37 | 38 | py3_ver=$(python3 -c "import sys; print(sys.version_info[1])") 39 | 40 | folder=${HOME}/src 41 | mkdir -p $folder 42 | 43 | echo "** Purge old opencv installation" 44 | sudo apt-get purge -y libopencv* 45 | 46 | echo "** Install requirements" 47 | sudo apt-get update 48 | sudo apt-get install -y build-essential make cmake cmake-curses-gui git g++ pkg-config curl 49 | sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libeigen3-dev libglew-dev libgtk2.0-dev 50 | sudo apt-get install -y libtbb2 libtbb-dev libv4l-dev v4l-utils qv4l2 v4l2ucp 51 | sudo apt-get install -y libdc1394-22-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev 52 | # sudo apt-get install -y libjasper-dev 53 | sudo apt-get install -y libjpeg8-dev libjpeg-turbo8-dev libtiff-dev libpng-dev 54 | sudo apt-get install -y libxvidcore-dev libx264-dev libgtk-3-dev 55 | sudo apt-get install -y libatlas-base-dev libopenblas-dev liblapack-dev liblapacke-dev gfortran 56 | sudo apt-get install -y qt5-default 57 | 58 | sudo apt-get install -y python3-dev python3-testresources 59 | rm -f $folder/get-pip.py 60 | wget https://bootstrap.pypa.io/get-pip.py -O $folder/get-pip.py 61 | sudo python3 $folder/get-pip.py 62 | sudo pip3 install protobuf 63 | sudo pip3 install -U numpy matplotlib 64 | 65 | if [ ! -f /usr/local/cuda/include/cuda_gl_interop.h.bak ]; then 66 | sudo cp /usr/local/cuda/include/cuda_gl_interop.h /usr/local/cuda/include/cuda_gl_interop.h.bak 67 | fi 68 | sudo patch -N -r - /usr/local/cuda/include/cuda_gl_interop.h < opencv/cuda_gl_interop.h.patch && echo "** '/usr/local/cuda/include/cuda_gl_interop.h' appears to be patched already. Continue..." 69 | 70 | echo "** Download opencv-3.4.8" 71 | cd $folder 72 | if [ ! -f opencv-3.4.8.zip ]; then 73 | wget https://github.com/opencv/opencv/archive/3.4.8.zip -O opencv-3.4.8.zip 74 | fi 75 | if [ -d opencv-3.4.8 ]; then 76 | echo "** ERROR: opencv-3.4.8 directory already exists" 77 | exit 78 | fi 79 | unzip opencv-3.4.8.zip 80 | cd opencv-3.4.8/ 81 | 82 | echo "** Building opencv..." 83 | mkdir build 84 | cd build/ 85 | 86 | cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ 87 | -D WITH_CUDA=ON -D CUDA_ARCH_BIN=${cuda_compute} -D CUDA_ARCH_PTX="" \ 88 | -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON \ 89 | -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON \ 90 | -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \ 91 | -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON \ 92 | -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF \ 93 | -D WITH_QT=ON -D WITH_OPENGL=ON .. 94 | make -j$(nproc) 95 | sudo make install 96 | sudo ldconfig 97 | 98 | python3 -c 'import cv2; print("python3 cv2 version: %s" % cv2.__version__)' 99 | 100 | echo "** Install opencv-3.4.8 successfully" 101 | -------------------------------------------------------------------------------- /install_opencv-4.5.5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # NVIDIA Corporation and its licensors retain all intellectual property 6 | # and proprietary rights in and to this software, related documentation 7 | # and any modifications thereto. Any use, reproduction, disclosure or 8 | # distribution of this software and related documentation without an express 9 | # license agreement from NVIDIA Corporation is strictly prohibited. 10 | # 11 | 12 | # The orginal script 'install_opencv4.0.0_Nano.sh' could be found here: 13 | # https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh 14 | # 15 | # I did some modification so that it installs opencv-3.4.8 instead. Refer 16 | # to my blog posts for more details. 17 | # 18 | # JK Jung, jkjung13@gmail.com 19 | 20 | set -e 21 | 22 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 23 | case ${chip_id} in 24 | "33" ) # Nano and TX1 25 | cuda_compute=5.3 26 | ;; 27 | "24" ) # TX2 28 | cuda_compute=6.2 29 | ;; 30 | "25" ) # AGX Xavier 31 | cuda_compute=7.2 32 | ;; 33 | * ) # default 34 | cuda_compute=5.3,6.2,7.2 35 | ;; 36 | esac 37 | 38 | py3_ver=$(python3 -c "import sys; print(sys.version_info[1])") 39 | 40 | folder=${HOME}/src 41 | mkdir -p $folder 42 | 43 | echo "** Purge old opencv installation" 44 | sudo apt-get purge -y libopencv* 45 | 46 | echo "** Install requirements" 47 | sudo apt-get update 48 | sudo apt-get install -y build-essential make cmake cmake-curses-gui git g++ pkg-config curl 49 | sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libeigen3-dev libglew-dev libgtk2.0-dev 50 | sudo apt-get install -y libtbb2 libtbb-dev libv4l-dev v4l-utils qv4l2 v4l2ucp 51 | sudo apt-get install -y libdc1394-22-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev 52 | # sudo apt-get install -y libjasper-dev 53 | sudo apt-get install -y libjpeg8-dev libjpeg-turbo8-dev libtiff-dev libpng-dev 54 | sudo apt-get install -y libxvidcore-dev libx264-dev libgtk-3-dev 55 | sudo apt-get install -y libatlas-base-dev libopenblas-dev liblapack-dev liblapacke-dev gfortran 56 | sudo apt-get install -y qt5-default 57 | 58 | sudo apt-get install -y python3-dev python3-testresources 59 | rm -f $folder/get-pip.py 60 | wget https://bootstrap.pypa.io/get-pip.py -O $folder/get-pip.py 61 | sudo python3 $folder/get-pip.py 62 | sudo pip3 install protobuf 63 | sudo pip3 install -U numpy matplotlib 64 | 65 | if [ ! -f /usr/local/cuda/include/cuda_gl_interop.h.bak ]; then 66 | sudo cp /usr/local/cuda/include/cuda_gl_interop.h /usr/local/cuda/include/cuda_gl_interop.h.bak 67 | fi 68 | sudo patch -N -r - /usr/local/cuda/include/cuda_gl_interop.h < opencv/cuda_gl_interop.h.patch && echo "** '/usr/local/cuda/include/cuda_gl_interop.h' appears to be patched already. Continue..." 69 | 70 | echo "** Download opencv-4.5.5" 71 | cd $folder 72 | if [ ! -f opencv-4.5.5.zip ]; then 73 | wget https://github.com/opencv/opencv/archive/4.5.5.zip -O opencv-4.5.5.zip 74 | wget https://github.com/opencv/opencv_contrib/archive/4.5.5.zip -O opencv_contrib.zip 75 | fi 76 | if [ -d opencv-4.5.5 ]; then 77 | echo "** ERROR: opencv-4.5.5 directory already exists" 78 | exit 79 | fi 80 | unzip opencv-4.5.5.zip 81 | unzip opencv_contrib.zip 82 | mv opencv-4.5.5 opencv 83 | mv opencv_contrib-4.5.5 opencv_contrib 84 | cd opencv/ 85 | 86 | echo "** Building opencv..." 87 | mkdir build 88 | cd build/ 89 | 90 | cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ 91 | -D OPENCV_EXTRA_MODULES_PATH=~/src/opencv_contrib/modules \ 92 | -D WITH_CUDA=ON -D CUDA_ARCH_BIN=${cuda_compute} -D CUDA_ARCH_PTX="" \ 93 | -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON \ 94 | -D ENABLE_NEON=ON -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON \ 95 | -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \ 96 | -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON \ 97 | -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF \ 98 | -D WITH_QT=ON -D WITH_OPENGL=ON .. 99 | make -j$(nproc) 100 | sudo make install 101 | sudo ldconfig 102 | 103 | python3 -c 'import cv2; print("python3 cv2 version: %s" % cv2.__version__)' 104 | 105 | echo "** Install opencv-4.5.5 successfully" 106 | -------------------------------------------------------------------------------- /install_protobuf-3.6.1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | folder=${HOME}/src 6 | mkdir -p $folder 7 | 8 | echo "** Install requirements" 9 | sudo apt-get install -y autoconf libtool 10 | 11 | echo "** Download protobuf-3.6.1 sources" 12 | cd $folder 13 | if [ ! -f protobuf-python-3.6.1.zip ]; then 14 | wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-python-3.6.1.zip 15 | fi 16 | if [ ! -f protoc-3.6.1-linux-aarch_64.zip ]; then 17 | wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-aarch_64.zip 18 | fi 19 | 20 | echo "** Install protoc" 21 | unzip protobuf-python-3.6.1.zip 22 | unzip protoc-3.6.1-linux-aarch_64.zip -d protoc-3.6.1 23 | sudo cp protoc-3.6.1/bin/protoc /usr/local/bin/protoc 24 | 25 | echo "** Build and install protobuf-3.6.1 libraries" 26 | export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 27 | cd protobuf-3.6.1/ 28 | ./autogen.sh 29 | ./configure --prefix=/usr/local 30 | make -j$(nproc) 31 | make check 32 | sudo make install 33 | sudo ldconfig 34 | 35 | echo "** Update python3 protobuf module" 36 | # remove previous installation of python3 protobuf module 37 | sudo pip3 uninstall -y protobuf 38 | sudo pip3 install Cython 39 | cd python/ 40 | # force compilation with c++11 standard 41 | sed -i '205s/if v:/if True:/' setup.py 42 | python3 setup.py build --cpp_implementation 43 | python3 setup.py test --cpp_implementation 44 | sudo python3 setup.py install --cpp_implementation 45 | 46 | echo "** Build protobuf-3.6.1 successfully" 47 | -------------------------------------------------------------------------------- /install_protobuf-3.8.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | folder=${HOME}/src 6 | mkdir -p $folder 7 | 8 | echo "** Install requirements" 9 | sudo apt-get install -y autoconf libtool 10 | 11 | echo "** Download protobuf-3.8.0 sources" 12 | cd $folder 13 | if [ ! -f protobuf-python-3.8.0.zip ]; then 14 | wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protobuf-python-3.8.0.zip 15 | fi 16 | if [ ! -f protoc-3.8.0-linux-aarch_64.zip ]; then 17 | wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protoc-3.8.0-linux-aarch_64.zip 18 | fi 19 | 20 | echo "** Install protoc" 21 | unzip protobuf-python-3.8.0.zip 22 | unzip protoc-3.8.0-linux-aarch_64.zip -d protoc-3.8.0 23 | sudo cp protoc-3.8.0/bin/protoc /usr/local/bin/protoc 24 | 25 | echo "** Build and install protobuf-3.8.0 libraries" 26 | export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 27 | cd protobuf-3.8.0/ 28 | ./autogen.sh 29 | ./configure --prefix=/usr/local 30 | make -j$(nproc) 31 | make check 32 | sudo make install 33 | sudo ldconfig 34 | 35 | echo "** Update python3 protobuf module" 36 | # remove previous installation of python3 protobuf module 37 | sudo apt-get install -y python3-pip 38 | sudo pip3 uninstall -y protobuf 39 | sudo pip3 install Cython 40 | cd python/ 41 | python3 setup.py build --cpp_implementation 42 | python3 setup.py test --cpp_implementation 43 | sudo python3 setup.py install --cpp_implementation 44 | 45 | echo "** Build protobuf-3.8.0 successfully" 46 | -------------------------------------------------------------------------------- /install_protobuf-3.9.2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | version=3.9.2 6 | 7 | folder=${HOME}/src 8 | mkdir -p $folder 9 | 10 | echo "** Install requirements" 11 | sudo apt-get install -y autoconf libtool 12 | 13 | echo "** Download protobuf-${version} sources" 14 | pushd $folder 15 | if [ ! -f protobuf-python-${version}.zip ]; then 16 | wget https://github.com/protocolbuffers/protobuf/releases/download/v${version}/protobuf-python-${version}.zip 17 | fi 18 | if [ ! -f protoc-${version}-linux-aarch_64.zip ]; then 19 | wget https://github.com/protocolbuffers/protobuf/releases/download/v${version}/protoc-${version}-linux-aarch_64.zip 20 | fi 21 | 22 | echo "** Install protoc" 23 | unzip protobuf-python-${version}.zip 24 | unzip protoc-${version}-linux-aarch_64.zip -d protoc-${version} 25 | sudo cp protoc-${version}/bin/protoc /usr/local/bin/protoc 26 | 27 | echo "** Build and install protobuf-${version} libraries" 28 | cd protobuf-${version}/ 29 | ./autogen.sh 30 | ./configure --prefix=/usr/local 31 | make -j$(nproc) 32 | #make check ### Disabled because "protobuf-test" would fail (JetPack-4.6)! 33 | sudo make install 34 | sudo ldconfig 35 | 36 | echo "** Update python3 protobuf module" 37 | # remove previous installation of python3 protobuf module 38 | sudo apt-get install -y python3-pip 39 | sudo pip3 uninstall -y protobuf 40 | sudo pip3 install Cython 41 | cd python/ 42 | export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 43 | python3 setup.py build --cpp_implementation 44 | python3 setup.py test --cpp_implementation 45 | sudo python3 setup.py install --cpp_implementation 46 | 47 | popd 48 | 49 | echo "** Build protobuf-${version} successfully" 50 | -------------------------------------------------------------------------------- /install_ssd-caffe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | config_file=`pwd`/caffe/Makefile.config.nano 6 | project_folder=${HOME}/project 7 | mkdir -p $project_folder 8 | 9 | echo "** Install requirements" 10 | sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-dev libhdf5-serial-dev protobuf-compiler 11 | sudo apt-get install -y --no-install-recommends libboost-all-dev 12 | sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev 13 | sudo apt-get install -y libatlas-base-dev libopenblas-dev 14 | 15 | echo "** Download SSD caffe" 16 | cd $project_folder 17 | git clone https://github.com/weiliu89/caffe.git ssd-caffe 18 | cd ssd-caffe 19 | git checkout ssd 20 | 21 | echo "** Install python3 requirements" 22 | # build python3 leveldb from source 23 | pushd /tmp 24 | wget https://pypi.python.org/packages/03/98/1521e7274cfbcc678e9640e242a62cbcd18743f9c5761179da165c940eac/leveldb-0.20.tar.gz 25 | tar xzvf leveldb-0.20.tar.gz 26 | cd leveldb-0.20 27 | python3 setup.py build 28 | sudo python3 setup.py install 29 | popd 30 | pkgs=`sed 's/[>=<].*$//' python/requirements.txt | grep -v leveldb | grep -v pyyaml` 31 | for pkg in $pkgs; do sudo pip3 install $pkg; done 32 | 33 | echo "** Building caffe..." 34 | cp $config_file Makefile.config 35 | make -j$(nproc) all test pycaffe 36 | 37 | # NOTE: runtest fails on Jetson Nano due to out of memory 38 | # make runtest 39 | 40 | ./build/tools/caffe time --gpu 0 --model ./models/bvlc_alexnet/deploy.prototxt 41 | 42 | PYTHONPATH=`pwd`/python python3 -c "import caffe; print('caffe version: %s' % caffe.__version__)" 43 | 44 | echo "** Build and test SSD caffe successfully" 45 | -------------------------------------------------------------------------------- /install_tensorflow-1.12.2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | script_path=$(realpath $0) 6 | patch_path=$(dirname $script_path)/tensorflow/tensorflow-1.12.2.patch 7 | trt_version=$(echo /usr/lib/aarch64-linux-gnu/libnvinfer.so.? | cut -d '.' -f 3) 8 | 9 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 10 | case ${chip_id} in 11 | "33" ) # Nano and TX1 12 | cuda_compute=5.3 13 | local_resources=2048.0,1.0,1.0 14 | ;; 15 | "24" ) # TX2 16 | cuda_compute=6.2 17 | local_resources=6144.0,6.0,1.0 18 | ;; 19 | "25" ) # AGX Xavier 20 | cuda_compute=7.2 21 | local_resources=8192.0,16.0,1.0 22 | ;; 23 | * ) # default 24 | cuda_compute=5.3,6.2,7.2 25 | local_resources=2048.0,1.0,1.0 26 | ;; 27 | esac 28 | 29 | folder=${HOME}/src 30 | mkdir -p $folder 31 | 32 | if pip3 list | grep tensorflow > /dev/null; then 33 | echo "ERROR: tensorflow is installed already" 34 | exit 35 | fi 36 | 37 | if ! which bazel > /dev/null; then 38 | echo "ERROR: bazel has not been installled" 39 | exit 40 | fi 41 | 42 | echo "** Install requirements" 43 | sudo apt-get install -y libhdf5-serial-dev hdf5-tools 44 | sudo pip3 install -U pip six numpy wheel setuptools mock h5py 45 | sudo pip3 install -U keras_applications 46 | sudo pip3 install -U keras_preprocessing 47 | 48 | export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH 49 | 50 | echo "** Download and patch tensorflow-1.12.2" 51 | pushd $folder 52 | if [ ! -f tensorflow-1.12.2.tar.gz ]; then 53 | wget https://github.com/tensorflow/tensorflow/archive/v1.12.2.tar.gz -O tensorflow-1.12.2.tar.gz 54 | fi 55 | tar xzvf tensorflow-1.12.2.tar.gz 56 | cd tensorflow-1.12.2 57 | 58 | patch -N -p1 < $patch_path && echo "tensorflow-1.12.2 source tree appears to be patched already. Continue..." 59 | 60 | echo "** Configure and build tensorflow-1.12.2" 61 | export TMP=/tmp 62 | PYTHON_BIN_PATH=$(which python3) \ 63 | PYTHON_LIB_PATH=$(python3 -c 'import site; print(site.getsitepackages()[0])') \ 64 | TF_CUDA_COMPUTE_CAPABILITIES=${cuda_compute} \ 65 | TF_CUDA_VERSION=10.0 \ 66 | TF_CUDA_CLANG=0 \ 67 | TF_CUDNN_VERSION=7 \ 68 | TF_NCCL_VERSION=1.3 \ 69 | TF_TENSORRT_VERSION=${trt_version} \ 70 | CUDA_TOOLKIT_PATH=/usr/local/cuda \ 71 | CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 72 | TENSORRT_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 73 | TF_NEED_IGNITE=0 \ 74 | TF_ENABLE_XLA=0 \ 75 | TF_NEED_OPENCL_SYCL=0 \ 76 | TF_NEED_COMPUTECPP=0 \ 77 | TF_NEED_ROCM=0 \ 78 | TF_NEED_CUDA=1 \ 79 | TF_NEED_TENSORRT=1 \ 80 | TF_NEED_OPENCL=0 \ 81 | TF_NEED_MPI=0 \ 82 | GCC_HOST_COMPILER_PATH=$(which gcc) \ 83 | CC_OPT_FLAGS="-march=native" \ 84 | TF_SET_ANDROID_WORKSPACE=0 \ 85 | ./configure 86 | bazel build --config=opt \ 87 | --config=cuda \ 88 | --local_resources=${local_resources} \ 89 | //tensorflow/tools/pip_package:build_pip_package 90 | bazel-bin/tensorflow/tools/pip_package/build_pip_package wheel/tensorflow_pkg 91 | 92 | echo "** Install tensorflow-1.12.2" 93 | #sudo pip3 install wheel/tensorflow_pkg/tensorflow-1.12.2-cp36-cp36m-linux_aarch64.whl 94 | sudo pip3 install wheel/tensorflow_pkg/tensorflow-1.12.2-*.whl 95 | 96 | popd 97 | python3 -c "import tensorflow as tf; print('tensorflow version: %s' % tf.__version__)" 98 | 99 | echo "** Build and install tensorflow-1.12.2 successfully" 100 | -------------------------------------------------------------------------------- /install_tensorflow-1.15.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | version=1.15.0 6 | script_path=$(realpath $0) 7 | patch_path=$(dirname $script_path)/tensorflow/tensorflow-${version}.patch 8 | trt_version=$(echo /usr/lib/aarch64-linux-gnu/libnvinfer.so.? | cut -d '.' -f 3) 9 | 10 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 11 | case ${chip_id} in 12 | "33" ) # Nano and TX1 13 | cuda_compute=5.3 14 | local_resources=2048.0,1.0,1.0 15 | ;; 16 | "24" ) # TX2 17 | cuda_compute=6.2 18 | local_resources=6144.0,6.0,1.0 19 | ;; 20 | "25" ) # AGX Xavier 21 | cuda_compute=7.2 22 | local_resources=8192.0,16.0,1.0 23 | ;; 24 | * ) # default 25 | cuda_compute=5.3,6.2,7.2 26 | local_resources=2048.0,1.0,1.0 27 | ;; 28 | esac 29 | 30 | folder=${HOME}/src 31 | mkdir -p $folder 32 | 33 | if pip3 list | grep tensorflow > /dev/null; then 34 | echo "ERROR: tensorflow is installed already" 35 | exit 36 | fi 37 | 38 | if ! which bazel > /dev/null; then 39 | echo "ERROR: bazel has not been installled" 40 | exit 41 | fi 42 | 43 | echo "** Install requirements" 44 | sudo apt-get install -y libhdf5-serial-dev hdf5-tools 45 | sudo pip3 install -U pip six wheel setuptools mock 46 | sudo pip3 install -U 'numpy<1.19.0' 47 | sudo pip3 install -U h5py==2.10.0 48 | sudo pip3 install pandas 49 | sudo pip3 install future 50 | sudo pip3 install -U keras_applications==1.0.8 --no-deps 51 | sudo pip3 install -U keras_preprocessing==1.1.2 --no-deps 52 | 53 | export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH 54 | 55 | echo "** Download and patch tensorflow-${version}" 56 | pushd $folder 57 | if [ ! -f tensorflow-${version}.tar.gz ]; then 58 | wget https://github.com/tensorflow/tensorflow/archive/v${version}.tar.gz \ 59 | -O tensorflow-${version}.tar.gz 60 | fi 61 | tar xzvf tensorflow-${version}.tar.gz 62 | cd tensorflow-${version} 63 | 64 | patch -N -p1 < $patch_path && \ 65 | echo "tensorflow-${version} source tree appears to be patched already. Continue..." 66 | 67 | echo "** Configure and build tensorflow-${version}" 68 | export TMP=/tmp 69 | PYTHON_BIN_PATH=$(which python3) \ 70 | PYTHON_LIB_PATH=$(python3 -c 'import site; print(site.getsitepackages()[0])') \ 71 | TF_CUDA_COMPUTE_CAPABILITIES=${cuda_compute} \ 72 | TF_CUDA_VERSION=10.0 \ 73 | TF_CUDA_CLANG=0 \ 74 | TF_CUDNN_VERSION=7 \ 75 | TF_TENSORRT_VERSION=${trt_version} \ 76 | CUDA_TOOLKIT_PATH=/usr/local/cuda \ 77 | CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 78 | TENSORRT_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 79 | TF_NEED_IGNITE=0 \ 80 | TF_ENABLE_XLA=0 \ 81 | TF_NEED_OPENCL_SYCL=0 \ 82 | TF_NEED_COMPUTECPP=0 \ 83 | TF_NEED_ROCM=0 \ 84 | TF_NEED_CUDA=1 \ 85 | TF_NEED_TENSORRT=1 \ 86 | TF_NEED_OPENCL=0 \ 87 | TF_NEED_MPI=0 \ 88 | GCC_HOST_COMPILER_PATH=$(which gcc) \ 89 | CC_OPT_FLAGS="-march=native" \ 90 | TF_SET_ANDROID_WORKSPACE=0 \ 91 | ./configure 92 | bazel build \ 93 | --config=opt \ 94 | --config=cuda \ 95 | --local_resources=${local_resources} \ 96 | //tensorflow/tools/pip_package:build_pip_package 97 | bazel-bin/tensorflow/tools/pip_package/build_pip_package wheel/tensorflow_pkg 98 | 99 | echo "** Install tensorflow-${version}" 100 | #sudo pip3 install wheel/tensorflow_pkg/tensorflow-${version}-cp36-cp36m-linux_aarch64.whl 101 | sudo pip3 install wheel/tensorflow_pkg/tensorflow-${version}-*.whl 102 | 103 | popd 104 | python3 -c "import tensorflow as tf; print('tensorflow version: %s' % tf.__version__)" 105 | 106 | echo "** Build and install tensorflow-${version} successfully" 107 | -------------------------------------------------------------------------------- /install_tensorflow-2.0.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | script_path=$(realpath $0) 6 | patch_path=$(dirname $script_path)/tensorflow/tensorflow-2.0.0.patch 7 | trt_version=$(echo /usr/lib/aarch64-linux-gnu/libnvinfer.so.? | cut -d '.' -f 3) 8 | 9 | chip_id=$(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) 10 | case ${chip_id} in 11 | "33" ) # Nano and TX1 12 | cuda_compute=5.3 13 | local_resources=2048.0,1.0,1.0 14 | ;; 15 | "24" ) # TX2 16 | cuda_compute=6.2 17 | local_resources=6144.0,6.0,1.0 18 | ;; 19 | "25" ) # AGX Xavier 20 | cuda_compute=7.2 21 | local_resources=8192.0,16.0,1.0 22 | ;; 23 | * ) # default 24 | cuda_compute=5.3,6.2,7.2 25 | local_resources=2048.0,1.0,1.0 26 | ;; 27 | esac 28 | 29 | folder=${HOME}/src 30 | mkdir -p $folder 31 | 32 | if pip3 list | grep tensorflow > /dev/null; then 33 | echo "ERROR: tensorflow is installed already" 34 | exit 35 | fi 36 | 37 | if ! which bazel > /dev/null; then 38 | echo "ERROR: bazel has not been installled" 39 | exit 40 | fi 41 | 42 | echo "** Install requirements" 43 | sudo apt-get install -y libhdf5-serial-dev hdf5-tools 44 | sudo pip3 install -U pip six numpy wheel setuptools mock h5py 45 | sudo pip3 install -U keras_applications 46 | sudo pip3 install -U keras_preprocessing 47 | 48 | export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH 49 | 50 | echo "** Download and patch tensorflow-2.0.0" 51 | pushd $folder 52 | if [ ! -f tensorflow-2.0.0.tar.gz ]; then 53 | wget https://github.com/tensorflow/tensorflow/archive/v2.0.0.tar.gz -O tensorflow-2.0.0.tar.gz 54 | fi 55 | tar xzvf tensorflow-2.0.0.tar.gz 56 | cd tensorflow-2.0.0 57 | 58 | patch -N -p1 < $patch_path && echo "tensorflow-2.0.0 source tree appears to be patched already. Continue..." 59 | 60 | echo "** Configure and build tensorflow-2.0.0" 61 | export TMP=/tmp 62 | PYTHON_BIN_PATH=$(which python3) \ 63 | PYTHON_LIB_PATH=$(python3 -c 'import site; print(site.getsitepackages()[0])') \ 64 | TF_CUDA_COMPUTE_CAPABILITIES=${cuda_compute} \ 65 | TF_CUDA_VERSION=10.0 \ 66 | TF_CUDA_CLANG=0 \ 67 | TF_CUDNN_VERSION=7 \ 68 | TF_TENSORRT_VERSION=${trt_version} \ 69 | CUDA_TOOLKIT_PATH=/usr/local/cuda \ 70 | CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 71 | TENSORRT_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 72 | TF_NEED_IGNITE=0 \ 73 | TF_ENABLE_XLA=0 \ 74 | TF_NEED_OPENCL_SYCL=0 \ 75 | TF_NEED_COMPUTECPP=0 \ 76 | TF_NEED_ROCM=0 \ 77 | TF_NEED_CUDA=1 \ 78 | TF_NEED_TENSORRT=1 \ 79 | TF_NEED_OPENCL=0 \ 80 | TF_NEED_MPI=0 \ 81 | GCC_HOST_COMPILER_PATH=$(which gcc) \ 82 | CC_OPT_FLAGS="-march=native" \ 83 | TF_SET_ANDROID_WORKSPACE=0 \ 84 | ./configure 85 | bazel build --config=opt \ 86 | --config=cuda \ 87 | --local_resources=${local_resources} \ 88 | //tensorflow/tools/pip_package:build_pip_package 89 | bazel-bin/tensorflow/tools/pip_package/build_pip_package wheel/tensorflow_pkg 90 | 91 | echo "** Install tensorflow-2.0.0" 92 | #sudo pip3 install wheel/tensorflow_pkg/tensorflow-2.0.0-cp36-cp36m-linux_aarch64.whl 93 | sudo pip3 install wheel/tensorflow_pkg/tensorflow-2.0.0-*.whl 94 | 95 | popd 96 | TF_CPP_MIN_LOG_LEVEL=3 python3 -c "import tensorflow as tf; tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR); print('tensorflow version: %s' % tf.__version__); print('tensorflow.test.is_built_with_cuda(): %s' % tf.test.is_built_with_cuda()); print('tensorflow.test.is_gpu_available(): %s' % tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None))" 97 | 98 | echo "** Build and install tensorflow-2.0.0 successfully" 99 | -------------------------------------------------------------------------------- /install_tensorflow-2.3.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ ! $(head -1 /etc/nv_tegra_release) =~ R32.*4\.[34] ]] ; then 6 | echo "ERROR: not JetPack-4.4" 7 | exit 1 8 | fi 9 | 10 | case $(cat /sys/module/tegra_fuse/parameters/tegra_chip_id) in 11 | "33" ) # Nano and TX1 12 | cuda_compute=5.3 13 | ;; 14 | "24" ) # TX2 15 | cuda_compute=6.2 16 | ;; 17 | "25" ) # Xavier NX and AGX Xavier 18 | cuda_compute=7.2 19 | ;; 20 | * ) # default 21 | cuda_compute=5.3,6.2,7.2 22 | ;; 23 | esac 24 | 25 | script_path=$(realpath $0) 26 | patch_path=$(dirname $script_path)/tensorflow/tensorflow-2.3.0.patch 27 | trt_version=$(echo /usr/lib/aarch64-linux-gnu/libnvinfer.so.? | cut -d '.' -f 3) 28 | 29 | src_folder=${HOME}/src 30 | mkdir -p $src_folder 31 | 32 | if pip3 list | grep tensorflow > /dev/null; then 33 | echo "ERROR: tensorflow is installed already" 34 | exit 1 35 | fi 36 | 37 | if ! which bazel > /dev/null; then 38 | echo "ERROR: bazel has not been installled" 39 | exit 1 40 | fi 41 | 42 | echo "** Install requirements" 43 | sudo apt-get install -y libhdf5-serial-dev hdf5-tools 44 | sudo pip3 install -U pip six 'numpy<1.19.0' wheel setuptools mock 'future>=0.17.1' 'gast==0.3.3' typing_extensions h5py 45 | sudo pip3 install -U keras_applications --no-deps 46 | sudo pip3 install -U keras_preprocessing --no-deps 47 | 48 | export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH 49 | 50 | echo "** Download and patch tensorflow-2.3.0" 51 | pushd $src_folder 52 | if [ ! -f tensorflow-2.3.0.tar.gz ]; then 53 | wget https://github.com/tensorflow/tensorflow/archive/v2.3.0.tar.gz -O tensorflow-2.3.0.tar.gz 54 | fi 55 | tar xzvf tensorflow-2.3.0.tar.gz 56 | cd tensorflow-2.3.0 57 | 58 | patch -N -p1 < $patch_path && echo "tensorflow-2.3.0 source tree appears to be patched already. Continue..." 59 | 60 | echo "** Configure and build tensorflow-2.3.0" 61 | export TMP=/tmp 62 | PYTHON_BIN_PATH=$(which python3) \ 63 | PYTHON_LIB_PATH=$(python3 -c 'import site; print(site.getsitepackages()[0])') \ 64 | TF_CUDA_COMPUTE_CAPABILITIES=${cuda_compute} \ 65 | TF_CUDA_VERSION=10.2 \ 66 | TF_CUDA_CLANG=0 \ 67 | TF_CUDNN_VERSION=8 \ 68 | TF_TENSORRT_VERSION=${trt_version} \ 69 | CUDA_TOOLKIT_PATH=/usr/local/cuda \ 70 | CUDNN_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 71 | TENSORRT_INSTALL_PATH=/usr/lib/aarch64-linux-gnu \ 72 | TF_NEED_IGNITE=0 \ 73 | TF_ENABLE_XLA=0 \ 74 | TF_NEED_OPENCL_SYCL=0 \ 75 | TF_NEED_COMPUTECPP=0 \ 76 | TF_NEED_ROCM=0 \ 77 | TF_NEED_CUDA=1 \ 78 | TF_NEED_TENSORRT=1 \ 79 | TF_NEED_OPENCL=0 \ 80 | TF_NEED_MPI=0 \ 81 | GCC_HOST_COMPILER_PATH=$(which gcc) \ 82 | CC_OPT_FLAGS="-march=native" \ 83 | TF_SET_ANDROID_WORKSPACE=0 \ 84 | ./configure 85 | bazel build --config=opt \ 86 | --config=cuda \ 87 | --config=noaws \ 88 | --local_cpu_resources=HOST_CPUS*0.25 \ 89 | --local_ram_resources=HOST_RAM*0.5 \ 90 | //tensorflow/tools/pip_package:build_pip_package 91 | bazel-bin/tensorflow/tools/pip_package/build_pip_package wheel/tensorflow_pkg 92 | 93 | echo "** Install tensorflow-2.3.0" 94 | #sudo pip3 install wheel/tensorflow_pkg/tensorflow-2.3.0-cp36-cp36m-linux_aarch64.whl 95 | sudo pip3 install wheel/tensorflow_pkg/tensorflow-2.3.0-*.whl 96 | 97 | popd 98 | 99 | TF_CPP_MIN_LOG_LEVEL=3 python3 -c "import tensorflow as tf; tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR); print('tensorflow version: %s' % tf.__version__); print('tensorflow.test.is_built_with_cuda(): %s' % tf.test.is_built_with_cuda()); print('tensorflow.test.is_gpu_available(): %s' % tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None))" 100 | 101 | echo "** Build and install tensorflow-2.3.0 successfully" 102 | -------------------------------------------------------------------------------- /opencv/cuda_gl_interop.h.patch: -------------------------------------------------------------------------------- 1 | --- cuda_gl_interop.h.bak 2019-05-14 13:22:48.260006308 +0800 2 | +++ cuda_gl_interop.h 2019-05-14 13:42:50.488005850 +0800 3 | @@ -58,13 +58,13 @@ 4 | 5 | #else /* __APPLE__ */ 6 | 7 | -#if defined(__arm__) || defined(__aarch64__) 8 | -#ifndef GL_VERSION 9 | -#error Please include the appropriate gl headers before including cuda_gl_interop.h 10 | -#endif 11 | -#else 12 | +//#if defined(__arm__) || defined(__aarch64__) 13 | +//#ifndef GL_VERSION 14 | +//#error Please include the appropriate gl headers before including cuda_gl_interop.h 15 | +//#endif 16 | +//#else 17 | #include 18 | -#endif 19 | +//#endif 20 | 21 | #endif /* __APPLE__ */ 22 | 23 | -------------------------------------------------------------------------------- /tegra-cam.py.lnk: -------------------------------------------------------------------------------- 1 | https://gist.github.com/jkjung-avt/86b60a7723b97da19f7bfa3cb7d2690e 2 | -------------------------------------------------------------------------------- /tensorflow/mnist.py: -------------------------------------------------------------------------------- 1 | """mnist.py 2 | 3 | Sample code from "TensorFlow 2 quickstart for experts": 4 | https://www.tensorflow.org/tutorials/quickstart/advanced 5 | """ 6 | 7 | 8 | from __future__ import absolute_import, division, print_function, unicode_literals 9 | 10 | import os 11 | 12 | import tensorflow as tf 13 | from tensorflow.keras.layers import Dense, Flatten, Conv2D 14 | from tensorflow.keras import Model 15 | 16 | os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 17 | tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) 18 | 19 | physical_devices = tf.config.experimental.list_physical_devices('GPU') 20 | tf.config.experimental.set_memory_growth(physical_devices[0], True) 21 | 22 | print('Fetching MNIST dataset...') 23 | 24 | mnist = tf.keras.datasets.mnist 25 | 26 | (x_train, y_train), (x_test, y_test) = mnist.load_data() 27 | x_train, x_test = x_train / 255.0, x_test / 255.0 28 | 29 | # Add a channels dimension 30 | x_train = x_train[..., tf.newaxis] 31 | x_test = x_test[..., tf.newaxis] 32 | 33 | train_ds = tf.data.Dataset.from_tensor_slices( 34 | (x_train, y_train)).shuffle(10000).batch(16) 35 | 36 | test_ds = tf.data.Dataset.from_tensor_slices((x_test, y_test)).batch(16) 37 | 38 | class MyModel(Model): 39 | def __init__(self): 40 | super(MyModel, self).__init__() 41 | self.conv1 = Conv2D(32, 3, activation='relu') 42 | self.flatten = Flatten() 43 | self.d1 = Dense(128, activation='relu') 44 | self.d2 = Dense(10, activation='softmax') 45 | 46 | def call(self, x): 47 | x = self.conv1(x) 48 | x = self.flatten(x) 49 | x = self.d1(x) 50 | return self.d2(x) 51 | 52 | # Create an instance of the model 53 | model = MyModel() 54 | 55 | loss_object = tf.keras.losses.SparseCategoricalCrossentropy() 56 | 57 | optimizer = tf.keras.optimizers.Adam() 58 | 59 | train_loss = tf.keras.metrics.Mean(name='train_loss') 60 | train_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='train_accuracy') 61 | 62 | test_loss = tf.keras.metrics.Mean(name='test_loss') 63 | test_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='test_accuracy') 64 | 65 | @tf.function 66 | def train_step(images, labels): 67 | with tf.GradientTape() as tape: 68 | predictions = model(images) 69 | loss = loss_object(labels, predictions) 70 | gradients = tape.gradient(loss, model.trainable_variables) 71 | optimizer.apply_gradients(zip(gradients, model.trainable_variables)) 72 | 73 | train_loss(loss) 74 | train_accuracy(labels, predictions) 75 | 76 | @tf.function 77 | def test_step(images, labels): 78 | predictions = model(images) 79 | t_loss = loss_object(labels, predictions) 80 | 81 | test_loss(t_loss) 82 | test_accuracy(labels, predictions) 83 | 84 | print('Start training...') 85 | 86 | EPOCHS = 5 87 | 88 | for epoch in range(EPOCHS): 89 | for images, labels in train_ds: 90 | train_step(images, labels) 91 | 92 | for test_images, test_labels in test_ds: 93 | test_step(test_images, test_labels) 94 | 95 | template = 'Epoch {}, Loss: {}, Accuracy: {}, Test Loss: {}, Test Accuracy: {}' 96 | print(template.format(epoch+1, 97 | train_loss.result(), 98 | train_accuracy.result()*100, 99 | test_loss.result(), 100 | test_accuracy.result()*100)) 101 | 102 | # Reset the metrics for the next epoch 103 | train_loss.reset_states() 104 | train_accuracy.reset_states() 105 | test_loss.reset_states() 106 | test_accuracy.reset_states() 107 | 108 | print('MNIST training done.') 109 | -------------------------------------------------------------------------------- /tensorflow/tensorflow-1.12.2.patch: -------------------------------------------------------------------------------- 1 | diff -Nrup a/tensorflow/contrib/lite/kernels/internal/BUILD b/tensorflow/contrib/lite/kernels/internal/BUILD 2 | --- a/tensorflow/contrib/lite/kernels/internal/BUILD 2019-05-17 14:02:19.855972274 +0800 3 | +++ b/tensorflow/contrib/lite/kernels/internal/BUILD 2019-05-17 15:28:25.051970304 +0800 4 | @@ -21,7 +21,6 @@ HARD_FP_FLAGS_IF_APPLICABLE = select({ 5 | NEON_FLAGS_IF_APPLICABLE = select({ 6 | ":arm": [ 7 | "-O3", 8 | - "-mfpu=neon", 9 | ], 10 | ":armeabi-v7a": [ 11 | "-O3", 12 | diff -Nrup a/third_party/aws.BUILD b/third_party/aws.BUILD 13 | --- a/third_party/aws.BUILD 2019-05-17 14:02:35.559972268 +0800 14 | +++ b/third_party/aws.BUILD 2019-05-17 15:27:45.535970319 +0800 15 | @@ -24,7 +24,9 @@ cc_library( 16 | "@org_tensorflow//tensorflow:raspberry_pi_armeabi": glob([ 17 | "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp", 18 | ]), 19 | - "//conditions:default": [], 20 | + "//conditions:default": glob([ 21 | + "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp", 22 | + ]), 23 | }) + glob([ 24 | "aws-cpp-sdk-core/include/**/*.h", 25 | "aws-cpp-sdk-core/source/*.cpp", 26 | -------------------------------------------------------------------------------- /tensorflow/tensorflow-1.15.0.patch: -------------------------------------------------------------------------------- 1 | diff -Nrup a/third_party/nccl/build_defs.bzl.tpl b/third_party/nccl/build_defs.bzl.tpl 2 | --- a/third_party/nccl/build_defs.bzl.tpl 2019-09-28 05:56:33.000000000 +0800 3 | +++ b/third_party/nccl/build_defs.bzl.tpl 2019-10-04 12:51:56.663973578 +0800 4 | @@ -40,7 +40,7 @@ def _rdc_copts(): 5 | # The global functions can not have a lower register count than the 6 | # device functions. This is enforced by setting a fixed register count. 7 | # https://github.com/NVIDIA/nccl/blob/f93fe9bfd94884cec2ba711897222e0df5569a53/makefiles/common.mk#L48 8 | - maxrregcount = "-maxrregcount=96" 9 | + maxrregcount = "-maxrregcount=80" 10 | 11 | return cuda_default_copts() + select({ 12 | "@local_config_cuda//cuda:using_nvcc": [ 13 | -------------------------------------------------------------------------------- /tensorflow/tensorflow-2.0.0.patch: -------------------------------------------------------------------------------- 1 | diff -Nrup a/third_party/nccl/build_defs.bzl.tpl b/third_party/nccl/build_defs.bzl.tpl 2 | --- a/third_party/nccl/build_defs.bzl.tpl 2019-09-28 05:56:33.000000000 +0800 3 | +++ b/third_party/nccl/build_defs.bzl.tpl 2019-10-04 12:51:56.663973578 +0800 4 | @@ -40,7 +40,7 @@ def _rdc_copts(): 5 | # The global functions can not have a lower register count than the 6 | # device functions. This is enforced by setting a fixed register count. 7 | # https://github.com/NVIDIA/nccl/blob/f93fe9bfd94884cec2ba711897222e0df5569a53/makefiles/common.mk#L48 8 | - maxrregcount = "-maxrregcount=96" 9 | + maxrregcount = "-maxrregcount=80" 10 | 11 | return cuda_default_copts() + select({ 12 | "@local_config_cuda//cuda:using_nvcc": [ 13 | -------------------------------------------------------------------------------- /tensorflow/tensorflow-2.3.0.patch: -------------------------------------------------------------------------------- 1 | diff -Nrup a/tensorflow/python/lib/core/bfloat16.cc b/tensorflow/python/lib/core/bfloat16.cc 2 | --- a/tensorflow/python/lib/core/bfloat16.cc 2020-09-11 15:47:48.636000000 +0800 3 | +++ b/tensorflow/python/lib/core/bfloat16.cc 2020-09-11 15:50:34.264000000 +0800 4 | @@ -660,26 +660,26 @@ bool Initialize() { 5 | const std::array compare_types = { 6 | {npy_bfloat16_, npy_bfloat16_, NPY_BOOL}}; 7 | 8 | - if (!register_ufunc("equal", CompareUFunc, 9 | + if (!register_ufunc("equal", (PyUFuncGenericFunction) CompareUFunc, 10 | compare_types)) { 11 | return false; 12 | } 13 | - if (!register_ufunc("not_equal", CompareUFunc, 14 | + if (!register_ufunc("not_equal", (PyUFuncGenericFunction) CompareUFunc, 15 | compare_types)) { 16 | return false; 17 | } 18 | - if (!register_ufunc("less", CompareUFunc, compare_types)) { 19 | + if (!register_ufunc("less", (PyUFuncGenericFunction) CompareUFunc, compare_types)) { 20 | return false; 21 | } 22 | - if (!register_ufunc("greater", CompareUFunc, 23 | + if (!register_ufunc("greater", (PyUFuncGenericFunction) CompareUFunc, 24 | compare_types)) { 25 | return false; 26 | } 27 | - if (!register_ufunc("less_equal", CompareUFunc, 28 | + if (!register_ufunc("less_equal", (PyUFuncGenericFunction) CompareUFunc, 29 | compare_types)) { 30 | return false; 31 | } 32 | - if (!register_ufunc("greater_equal", CompareUFunc, 33 | + if (!register_ufunc("greater_equal", (PyUFuncGenericFunction) CompareUFunc, 34 | compare_types)) { 35 | return false; 36 | } 37 | diff -Nrup a/third_party/nccl/build_defs.bzl.tpl b/third_party/nccl/build_defs.bzl.tpl 38 | --- a/third_party/nccl/build_defs.bzl.tpl 2020-09-10 14:39:56.212000000 +0800 39 | +++ b/third_party/nccl/build_defs.bzl.tpl 2020-09-10 14:39:27.760000000 +0800 40 | @@ -40,7 +40,7 @@ def _rdc_copts(): 41 | # The global functions can not have a lower register count than the 42 | # device functions. This is enforced by setting a fixed register count. 43 | # https://github.com/NVIDIA/nccl/blob/f93fe9bfd94884cec2ba711897222e0df5569a53/makefiles/common.mk#L48 44 | - maxrregcount = "-maxrregcount=96" 45 | + maxrregcount = "-maxrregcount=80" 46 | 47 | return cuda_default_copts() + select({ 48 | "@local_config_cuda//cuda:using_nvcc": [ 49 | --------------------------------------------------------------------------------