Deploy Framework on Jetson TX2

Deploy Framework on Jetson TX2

NVIDIA Jetson TX2 is an AI supercomputer on a module, powered by NVIDIA Pascal™ architecture. Best of all, it packs this performance into a small, power-efficient form factor that’s ideal for intelligent edge devices like robots, drones, smart cameras, and portable medical devices. It supports all the features of the Jetson TX1 module while enabling bigger, more complex deep neural networks.

NVIDIA JetPack SDK is the most comprehensive solution for building AI applications. Use the JetPack installer to flash your Jetson Developer Kit with the latest OS image, to install developer tools for both host PC and Developer Kit, and to install the libraries and APIs, samples, and documentation needed to jumpstart your development environment.

JetPack 3.2 with L4T R28.2 is the latest production software release for NVIDIA Jetson TX2, Jetson TX2i and Jetson TX1. It bundles all the Jetson platform software, including TensorRT, cuDNN, CUDA Toolkit, VisionWorks, GStreamer, and OpenCV, all built on top of L4T with LTS Linux kernel. Highlights include support for TensorFlow models, up to 15% perf/W improvement for DL applications, out-of-the-box kernel support for Docker, and support for Ubuntu 16.04 on your host PC.

TensorRT 3.0 GA TensorRT is a high performance deep learning inference runtime for image classification, segmentation, and object detection neural networks. It speeds up deep learning inference as well as reducing the runtime memory footprint for convolutional and deconv neural networks.
cuDNN 7.0.5 CUDA Deep Neural Network library provides high-performance primitives for all deep learning frameworks. It includes support for convolutions, activation functions and tensor transformations.
VisionWorks 1.6 VisionWorks is a software development package for Computer Vision (CV) and image processing. It Includes VPI (Vision Programming Interface), a set of optimized CV primitives for use by CUDA developers. The NVX library enables direct access to VPI, and the OVX library enables indirect access to VPI via OpenVX framework.
CUDA 9.0 CUDA Toolkit provides a comprehensive development environment for C and C++ developers building GPU-accelerated applications. The toolkit includes a compiler for NVIDIA GPUs, math libraries, and tools for debugging and optimizing the performance of your applications.
Multimedia API The Jetson Multimedia API package provides low level APIs for flexible application development.
Camera application API: libargus offers a low-level frame-synchronous API for camera applications, with per frame camera parameter control, multiple (including synchronized) camera support, and EGL stream outputs. RAW output CSI cameras needing ISP can be used with either libargus or GStreamer plugin. In either case, the V4L2 media-controller sensor driver API is used.
Sensor driver API: V4L2 API enables video decode, encode, format conversion and scaling functionality. V4L2 for encode opens up many features like bit rate control, quality presets, low latency encode, temporal tradeoff, motion vector maps, and more.
L4T The NVIDIA® Tegra® Linux Driver Package supports development on the Jetson Platform.

Product L4T Version Notes
Jetson TX2
Jetson TX2i
Jetson TX1
28.2 64-bit Ubuntu 16.04
Development Tools NVIDIA System Profiler 4.0 is a multi-core CPU PC sampling profiler that provides an interactive view of captured profiling data, helping improve overall application performance.

Tegra Graphics Debugger 2.5 is a console-grade tool that allows developers to debug and profile OpenGL ES 2.0, 3.0, 3.1, and 3.2, OpenGL 4.3-4.6, enabling developers to get the most out of the Jetson platform.

 

Prerequisites with Another Ubuntu System to Flash OS on Jetson TX2

  • Linux operating system( ubuntu 16.04 system would be better ) or virtual machine with Linux operating system.
  • The system with at least 16 GB of free disk space.

1. Download the JetPack package “JetPack 3.2 with L4T R28.2 “. The size of image is about 35.5MB. The website maybe need the Nvidia account login in.
2. Put the JetPack package into the new directory (~/JetsonTX2/), and then open into the terminal:

2.1. If the authority is needed, please run the command below:

$ chmod +x ./JetPack-L4T-3.2-linux-x64_b196.run

2.1. If the authority is ok, please run the command below:

$ sudo ./JetPack-L4T-3.2-linux-x64_b196.run

3. Click the Next to continue the JetPack 3.2 Installation, and we use the default directory to save the download software package.

4. We choose the Jetson TX2 Development Environment to control the components manager.

5. View the components manager, the first thing is we have to install the all things on the host ubuntu system for the best. If we want to flash the TX2 system to get a new Jetson TX2 system environment, the tab of “Flash OS Image to Target” should be in action with “install”. If not, in action with “no action”.

6. The important software packages for the framework we must be installed are as list. The Jetpack 3.2 will setup the OpenCV3.3.1, which is suitable for the framework.

7. After click the next button and then accept all the terms and conditions, we wait for the installation on the host ubuntu system.When the installation is done, we have to connect the host ubuntu system and the TX2 system with a router which has the access to the Internet by the netting twines.

8. Switch of the TX2 development board and remove the AC adapter from the power port.
9. Connect the Recovery USB to an USB Port on the Host computer via the Micro-B USB cable.
10. Connect the power adapter to the TX2 development board.
11. Press the power button once to boot up the system. While pressing the Recovery Button, use a pin to press and release Reset Button once. Finally, release the Recovery Button.
12. Run “lsusb” from the Host computer to check if the TX2 has entered the Recovery Mode successfully. The TX2 has entered Recovery Mode successfully if “NVIDIA Crop.”is displayed on the screen, and then push the enter button into the main terminal. If no such text is displayed, repeat steps 8 to 12.

Tips and Problems:

Problem 1  : the terminal on host ubuntu system return some issue about “The CPU Bootloader ..”
Solutions 1: rerun the install process.

Problem 2  : the apt-get update process in terminal on host ubuntu system is slowly or waiting for no action
Solutions 2: pull out the netting twine then connect the Jetson TX2 to the wifi network, and the run apt-get update (Seeing the Update apt-get sources link on Jetson TX2) first. when the process is done and connect the TX2 with the router and rerun the install process without flashing the OS on Jetson TX2.

Update apt-get sources link on Jetson TX2

During the install process of JetPack 3.2 on the Nvidia Jetson TX2 device, the problem we faces is that the software source updates maybe slowly or with errors. So we have to change the source of software (apt-get) differ from other ubuntu 16.04 system. The list I used is ok for my test.

deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse

Or other sources:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main restricted universe multiverse 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main restricted universe multiverse 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main restricted universe multiverse 
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted 
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main universe restricted

After the apt-get sources update process is done, you may find some issues about the PUBLIC KEY of cuda or tensorrt. So you have to run the command below to avoid these warnings:

$ sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
$ sudo apt-key add /var/nv-tensorrt-repo-ga-cuda9.0-trt3.0.4-20180208/7fa2af80.pub

Install Packages After Software Update

Facing a new system installized on Jetson TX2, we have to installize some software packages on the system.

$ sudo apt-get install build-essential
$ sudo apt-get install cmake git autoconf automake libtool curl make g++ unzip
  # qt and qtcreator tools
$ sudo apt-get install qt5-default qtcreator -y
  # boost library
$ sudo apt-get install --no-install-recommends libboost-all-dev -y
  # openblas library
$ sudo apt-get install libatlas-base-dev -y

Install Eigen 3.3.4 Before Setup Caffe2

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.

1. Download the Eigen 3.3.4 package “Eigen-3.3.4.zip“. The size of image is about 3.05MB.
2. unzip the Eigen 3.3.4 package and there are two ways to use the Eigen packages.
3. One way: You can use right away the headers in the Eigen/ subdirectory. In order to install, just copy this Eigen/ subdirectory to your favorite location. If you also want the unsupported features, copy the unsupported/ subdirectory too.
4. Another way : enter this directory with the command:

$ cd ~/Downloads/eigen-eigen-5a0156e40feb
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/ ..
$ sudo make install

Install Caffe2

Caffe2 is a deep learning framework that provides an easy and straightforward way for you to experiment with deep learning and leverage community contributions of new models and algorithms. You can bring your creations to scale using the power of GPUs in the cloud or to the masses on mobile with Caffe2’s cross-platform libraries.

1. Download the Caffe2 source code from GitHub use the command list.

$ git clone --recursive https://github.com/pytorch/pytorch.git && cd pytorch
$ git submodule update --init

2. According to the script /scripts/build_tegra_x1.sh. we renew a script under the same directory “scripts” with the name “build_tegra_x2.sh”, and the datails as list:

#!/bin/bash
##############################################################################
# Example command to build Caffe2 on Tegra X2.
##############################################################################
# 
# This script shows how one can build a Caffe2 binary for NVidia's TX2.
# The build script assumes that you have the most recent libraries installed
# via the JetPack toolkit available at
#     https://developer.nvidia.com/embedded/jetpack
# and it assumes that we are starting from a fresh system after the jetpack
# installation. If you have already installed some of the dependencies, you
# may be able to skip quite a few of the apt-get installs.

CAFFE2_ROOT="$( cd "$(dirname -- "$0")"/.. ; pwd -P)"
echo "Caffe2 codebase root is: $CAFFE2_ROOT"
BUILD_ROOT=${BUILD_ROOT:-"$CAFFE2_ROOT/build"}
mkdir -p $BUILD_ROOT
echo "Build Caffe2 raspbian into: $BUILD_ROOT"

# obtain necessary dependencies
echo "Installing dependencies."
sudo apt-get install \
  libgflags-dev \
  libgoogle-glog-dev \
  libprotobuf-dev \
  protobuf-compiler

# obtain optional dependencies that are usually useful to have.
echo "Installing optional dependencies."
sudo apt-get install \
  libleveldb-dev \
  liblmdb-dev \
  libpython-dev \
  libsnappy-dev \
  python-numpy \
  python-pip \
  python-protobuf

# Update the pip tools
sudo pip install --upgrade pip

# Obtain python hypothesis, which Caffe2 uses for unit testing. Note that
# the one provided by apt-get is quite old so we install it via pip
sudo pip install hypothesis \
  pybind11

# Install the six module, which includes Python 2 and 3 compatibility utilities,
# and is required for Caffe2
sudo pip install six \
  future

# Now, actually build the android target.
echo "Building caffe2"
cd $BUILD_ROOT

# CUDA_USE_STATIC_CUDA_RUNTIME needs to be set to off so that opencv can be
# properly used. Otherwise, opencv will complain that opencv_dep_cudart cannot
# be found.
cmake "$CAFFE2_ROOT" -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \
    || exit 1

sudo make install -j 8 || exit 1

3. Open the terminal in the directory “scripts” to run this command to start the caffe2 installation.

$ chmod +x build_tegra_x2.sh
$ ./build_tegra_x2.sh

4. Run this to see if your Caffe2 installation was successful.

$ cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"

Tips and Problems:

Problem   : if the result return “Failure” and then put “from caffe2.python import core” in python environment we get the issue about “TypeError: __init__() got an unexpected keyword argument ‘syntax'”.
Solutions  : This is the problem about the protobuf version in python. so we have to reinstall the protobuf on the target system.

$ sudo pip uninstall protobuf
$ pip install protobuf

发表评论