Jetson TX2 Document

  Nvidia Jetson stands for a series of computation processor boards from Nvidia. The Jetson TK1, TX1 and TX2 models are all are carrying a Tegra processor from Nvidia. Nvidia claims that it 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. If you want to know more useful information about Jetson TX2, you can scan Nvidia Jetson.

Jetson TX2

Introduction:

  Because Jeston TX2 is so different from the other PC installed Ubuntu16.04, I reconized that it needs to write an article to guide other people who are the hardware and software developers and wanna learn it more to install and configure Jeston TX2. Finally, I am enormously grateful for the help from JetsonHacks, it provides so many useful tutorials and sources which is built in JetsonHacks Github.

1.Install JetPack(Ubuntu):

  When we get the Jetson TX2, it already installed an origin system(Ubuntu), but it has little usefulness. If we do use actraly to develop it for Deep Learning or other way to play what you want, you need to install the official system JetPack(This article is based on JetPack 3.1 which introduces L4T 28.1).

Release Highlight For JetPack 3.1 on Jetson TX2:

  • New L4T Production Release 28.1
  • TensorRT 2.1
  • cuDNN v6.0
  • Multimedia API v28.1
    • New functionality
      • TNRv2 (Temporal Noise Reduction)
        • High quality spatio-temporal noise reduction using GPU. Recommended for applications where low light video quality is important and GPU requirement is acceptable. Typical GPU utilization is <8.5% for 1080p30fps operation on Jetson TX1.
      • Piecewise linear WDR Support
        • ISP now supports cameras with “built-in WDR” that combine multiple exposures on-sensor and transmit the result with a piecewise linear encoding. Functionality verified using Sony IMX-185 (and reference driver is included). This feature does not include support for other WDR technologies such as DOL or spatial interleaving.
    • New samples
      • How to share CUDA buffer with v412 camera and then process color conversion (YUYV to RGB) with CUDA algorithm.
      • How to render video stream (YUV) or UI (RGB) with Tegra DRM (Direct Rendering Manager), i.e. rendering support for non-X11 and lightweight display system. Tegra DRM is implemented in user-space and is compatible with standard DRM 2.0.

        Note:

        When you start to install JetPack, you need to prepare something necessary.
  1. An desktop or laptop computer with an Intel or AMD x86 processor.

  2. A Micro USB and An Ethernet cable which will connect your PC and Jetson TX2.

  3. LAN(Local Area Network).

    Installing Step:

  4. First Step: Download JetPack

  5. Second Step: Run JetPack on your PC

    • Cd your file’s path.

      ~/Downloads```
      1
      2
      - Set the file executable permission.<br>
      ```chmod +x ./JetPack-L4T-3.1-linux-x64.run
    • Run it.

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      3.  <font color=red>**Third Step:**</font> Installing Interface
      - Read and watch it conscientiously. If it is no choice for you, you can **click next** no worry about it.
      - Full install or make your choice. As for me, I choosed no action OpenCV because this version called **OpenCV4Tegra** and some libraries require different modules and such that require upstream OpenCV versions.
      ![InstallFace](https://upload-images.jianshu.io/upload_images/9830587-8b92b3183a13185c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - Accept **all licenses**.
      - Select the **network layout**(I recommend you select the first way.).
      ![002.png](https://upload-images.jianshu.io/upload_images/9830587-d23dbdac14611b0a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - Then you will select the network interface and it will show that all the **network card** in your PC. You can run the **`ifconfig`** command on your PC terminal, and choose the device which has IP net or is in your LAN. Such like this:
      ![Network Device](https://upload-images.jianshu.io/upload_images/9830587-66f7f8c9aa995230.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - So you need to choose the wlp4s0 device.(The picture is catch by Internet, not my PC show. You should make choice depending on your PC.)
      ![003.png](https://upload-images.jianshu.io/upload_images/9830587-345ca456dd9257ec.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - Clicking the next, and you will obtain the interface from terminal where show you how to put your Jetson TX2 to force **USB Recovery Mode** and if you are ready, press the **Enter key**.
      1. **Power off your device**, the best way you do is that shutdown your Jetson TX2 and remove the power adapter for 3 seconds.
      2. Connect **Your PC** up to **TX2** with **Micro-USB**.
      3. **Power on your device**, and **immediately press and hold** the **RECOVERY** button(REC on your board), meanwhile press the **RESET**(RES on your board) button and release it. If you see the TX2 board flash it's light for a while, that means that you are successful in Recovery Mode.
      ![004.png](https://upload-images.jianshu.io/upload_images/9830587-2a0a8d188942f428.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      4. Also you can run `lsusb` in your PC terminal to show whether you are successful.(You can also skip this step.)
      ![005.png](https://upload-images.jianshu.io/upload_images/9830587-b8b7ced8966c8119.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - Installing Process will spend some time, then the Jetson TX2 will **power on** and your PC will connect it by SSH(automatic).
      ![006.png](https://upload-images.jianshu.io/upload_images/9830587-d72b8121cc6d4110.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/620)
      - Finish in installing and you can **remove all packages** about JetPack.


      ## 2.Install Tensorflow:
      &emsp;&emsp;TensorFlow is one of the major deep learning systems. Created at Google, it is an open-source software library for machine intelligence. The Jetson TX2 ships with TensorRT. TensorRT is what is called an “Inference Engine“, the idea being that large machine learning systems can train models which are then transferred over and “run” on the Jetson.
      <br>&emsp;&emsp;There are two ways to install Tensorflow in Jetson TX2, this article just show you install by wheel file. Because when I build the tensorflow by myself, I got a error: **locale en_US**, the issue address: https://github.com/bazelbuild/bazel/issues/4483.
      #### Build Information and Tensorflow Version:
      - L4T 28.1 (JetPack 3.1)
      - CUDA 8.0
      - cuDNN 6.0
      * Tensorflow Version 1.3.0
      * Built with CUDA support
      #### Install Preparation:
      1. Download the wheel file from https://github.com/jetsonhacks/installTensorFlowJetsonTX.git.
      2. Install the matching pip for your Python installation and install tensorflow_wheel_file in your download path.
      <br>If you are Chinese, you can choose update your apt-sources like the 3 step next.
      - **Python 2.7**

      sudo apt-get install -y python-pip python-dev
      pip install

      1
      - **Python 3.5**

      sudo apt-get install -y python3-pip python3-dev
      pip3 install

      1
      2
      3. **Update apt-sources:(For Chinese)**
      - CD your apt-sources path.

      cd /etc/apt

      1
      2
      3
      - Edit the sources file.
      1. `sudo gedit ./sources.list`
      2. Replace all the text by this:

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

      1
      - Update apt-sources.

      sudo apt-get update

      1
      2
      3
      4
      5
      6
              
      ## 3.Build OpenCV:
      #### Background:
      &emsp;&emsp;JetPack can install a CPU and GPU accelerated version of the OpenCV libraries, called OpenCV4Tegra, on the Jetson. OpenCV4Tegra is version 2.4.13 as of this writing. This is great for many applications, especially when you are writing your own apps. However, some libraries require different modules and such that require upstream OpenCV versions.
      #### Installation:
      - Download the sources and build OpenCV:

      git clone https://github.com/jetsonhacks/buildOpenCVTX2.git
      cd buildOpenCVTX2
      ./buildOpenCV.sh

      1
      **Note:** If you need the OpenCV which is also working in **python3**, you should open the buildOpenCV.sh file and change it like this:

      Change the BUILD_opencv_python3=OFF to ON
      Also you can make the building in python2 OFF

      1
      - CD your download path and make bulid:

      cd ~/opencv/build
      sudo make install

      1
      2
      3
      4
      - Check your library vaild:
      ```python3
      import cv2
      cv2.__version__

Note:

1.Use GStreamer and OpenCV Capture the Image of Camera

  • As I think, there are so many people who have theirselves tasks or goals, so I copy other developer’s code to show how to use the camera in Jetson TX2. What you need is up to you.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    # --------------------------------------------------------
    # Camera sample code for Tegra X2/X1
    #
    # This program could capture and display video from
    # IP CAM, USB webcam, or the Tegra onboard camera.
    # Refer to the following blog post for how to set up
    # and run the code:
    # https://jkjung-avt.github.io/tx2-camera-with-python/
    #
    # Written by JK Jung <jkjung13@gmail.com>
    # --------------------------------------------------------

    import sys
    import argparse
    import cv2
    import numpy as np

    windowName = "CameraDemo"

    def parse_args():
    """
    Parse input arguments
    """
    parser = argparse.ArgumentParser(description=
    "Capture and display live camera video on Jetson TX2/TX1")
    parser.add_argument("--rtsp", dest="use_rtsp",
    help="use IP CAM (remember to also set --uri)",
    action="store_true")
    parser.add_argument("--uri", dest="rtsp_uri",
    help="RTSP URI string, e.g. rtsp://192.168.1.64:554",
    default=None, type=str)
    parser.add_argument("--latency", dest="rtsp_latency",
    help="latency in ms for RTSP [200]",
    default=200, type=int)
    parser.add_argument("--usb", dest="use_usb",
    help="use USB webcam (remember to also set --vid)",
    action="store_true")
    parser.add_argument("--vid", dest="video_dev",
    help="video device # of USB webcam (/dev/video?) [1]",
    default=1, type=int)
    parser.add_argument("--width", dest="image_width",
    help="image width [1920]",
    default=1920, type=int)
    parser.add_argument("--height", dest="image_height",
    help="image width [1080]",
    default=1080, type=int)
    args = parser.parse_args()
    return args

    def open_cam_rtsp(uri, width, height, latency):
    gst_str = ("rtspsrc location={} latency={} ! rtph264depay ! h264parse ! omxh264dec ! "
    "nvvidconv ! video/x-raw, width=(int){}, height=(int){}, format=(string)BGRx ! "
    "videoconvert ! appsink").format(uri, latency, width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

    def open_cam_usb(dev, width, height):
    # We want to set width and height here, otherwise we could just do:
    # return cv2.VideoCapture(dev)
    gst_str = ("v4l2src device=/dev/video{} ! "
    "video/x-raw, width=(int){}, height=(int){}, format=(string)RGB ! "
    "videoconvert ! appsink").format(dev, width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

    def open_cam_onboard(width, height):
    # On versions of L4T previous to L4T 28.1, flip-method=2
    # Use Jetson onboard camera
    gst_str = ("nvcamerasrc ! "
    "video/x-raw(memory:NVMM), width=(int)2592, height=(int)1458, format=(string)I420, framerate=(fraction)30/1 ! "
    "nvvidconv ! video/x-raw, width=(int){}, height=(int){}, format=(string)BGRx ! "
    "videoconvert ! appsink").format(width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

    def open_window(windowName, width, height):
    cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
    cv2.resizeWindow(windowName, width, height)
    cv2.moveWindow(windowName, 0, 0)
    cv2.setWindowTitle(windowName, "Camera Demo for Jetson TX2/TX1")

    def read_cam(windowName, cap):
    showHelp = True
    showFullScreen = False
    helpText = "'Esc' to Quit, 'H' to Toggle Help, 'F' to Toggle Fullscreen"
    font = cv2.FONT_HERSHEY_PLAIN
    while True:
    if cv2.getWindowProperty(windowName, 0) < 0: # Check to see if the user closed the window
    # This will fail if the user closed the window; Nasties get printed to the console
    break;
    ret_val, displayBuf = cap.read();
    if showHelp == True:
    cv2.putText(displayBuf, helpText, (11,20), font, 1.0, (32,32,32), 4, cv2.LINE_AA)
    cv2.putText(displayBuf, helpText, (10,20), font, 1.0, (240,240,240), 1, cv2.LINE_AA)
    cv2.imshow(windowName, displayBuf)
    key = cv2.waitKey(10)
    if key == 27: # ESC key: quit program
    break
    elif key == ord('H') or key == ord('h'): # toggle help message
    showHelp = not showHelp
    elif key == ord('F') or key == ord('f'): # toggle fullscreen
    showFullScreen = not showFullScreen
    if showFullScreen == True:
    cv2.setWindowProperty(windowName, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
    else:
    cv2.setWindowProperty(windowName, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_NORMAL)

    if __name__ == "__main__":
    args = parse_args()
    print("Called with args:")
    print(args)
    print("OpenCV version: {}".format(cv2.__version__))

    if args.use_rtsp:
    cap = open_cam_rtsp(args.rtsp_uri, args.image_width, args.image_height, args.rtsp_latency)
    elif args.use_usb:
    cap = open_cam_usb(args.video_dev, args.image_width, args.image_height)
    else: # by default, use the Jetson onboard camera
    cap = open_cam_onboard(args.image_width, args.image_height)

    if not cap.isOpened():
    sys.exit("Failed to open camera!")

    open_window(windowName, args.image_width, args.image_height)
    read_cam(windowName, cap)

    cap.release()
    cv2.destroyAllWindows()

2. Opening the Max performance of TX2

  • Jetson TX2 consists of a CPU and a GPU cluster. Dual - core CPU clusters composed of 2 processors and quad - core ARM Cortex-A57 in Denver, connected by a high-performance interconnect architectures.
  • Next I will list all modes of Jetson TX2 and the detail about it.
nvpmodel mode definition
Model Model Name Denver 2 频率 ARM A57 Frequency GPU频率
0 Max-N 2 2.0 GHz 4 2.0 GHz 1.30 GHz
1 Max-Q 0 4 1.2 GHz 0.85 GHz
2 Max-P Core-All 2 1.4 GHz 4 1.4 GHz 1.12 GHz
3 Max-P ARM 0 4 2.0 GHz 1.2 GHz
4 Max-P Denver 2 2.0 GHz 0 1.2 GHz
  • Check the mode Version:

    1
    sudo nvpmodel -q –verbose
  • Open the Max Power:

    1
    sudo nvpmodel -m 0
  • Show the Information of GPU:

    1
    2
    3
    4
    5
    6
    7
    sudo tegrastats
    #If you see some cpus not opening, you can run like this:
    sudo su
    echo 1 > /sys/devices/system/cpu/cpu1/online

    #执行~/jetson_clocks.sh可以开启最大频率
    ~/jetson_clocks.sh

3. About Host PC Failed to Fetch(sudo apt-get update failed)

1
2
3
4
sudo apt-get remove .*:arm64
sudo dpkg --remove-architecture arm64
#Then you can update your apt.
sudo apt-get update
Mikoy Chinese wechat
Subscribe my public wechat account by scanning.

--------------------   ENDING   --------------------