Friday 3 February 2017

How to install JetPack on Jetson TX1

Limiting factors in the real-time machine learning on the embedded devices are both hardware and software. Hardware with high processing power usually consumes lots of energy and there is a lack of Machine Learning software support for embedded platforms. NVIDIA provides solution for this covering both constraints:
  • Jetson boards offer low-power, portable hardware platform for real-time training and inference, supported by the multi-core GPU
  • JetPack is a set of tools (including those made for parallel processing and machine learning) that can be deployed onto Jetson and which make NVIDIA Jetson Embedded Platform

Jetson


There are two Jetson Developer Kit platforms, based on the Tegra SoC (System on Chip): TK1 (based on Tegra K1) and TX1 (based on Tegra X1).

Jetson TX1 Developer Kit:

  • Tegra X1 processor (under the heath sink)
  • carrier board with various interfaces

Tegra X1:

  • NVIDIA Maxwell™ GPU with 256 NVIDIA® CUDA® Cores
    • (K1 uses NVIDIA Kepler GPU with 192 CUDA Cores)
  • Quad-core ARM® Cortex®-A57 MPCore Processor
  • 4 GB LPDDR4 Memory
  • 16 GB eMMC 5.1 Flash Storage
  • 802.11ac WiFi
  • Bluetooth
  • runs Ubuntu Linux which includes proprietary Linux for Tegra ("L4T") device drivers

Carrier board:

  • 6x CSI outputs for a half-dozen Raspberry Pi-style cameras
  • 2x DSI outputs 
  • 1 eDP 1.4 
  • 1 eDP 1.2
  • HDMI 2.0
  • Storage: either SD cards or SATA
  • 3x USB 3.0
  • 3x USB 2.0
  • Gigabit Ethernet
  • PCIe x1
  • PCIe x4
  • GPIOs, UARTs, SPI and I2C busses

Why Jetson?

  • small power consumption (less than 10W) so suitable for battery-powered, portable devices (drones, robots etc...) 
  • big processing power for embedded visual, AI, GPU computing

Jetson TX1 Unboxing







JetPack


In my recent posts I wrote about installing some of NVIDIA's frameworks - CUDA (for parallel computing using GPU) and cuDNN (Neural Network system) on a desktop machine running Ubuntu (16.04; with CUDA-compatible graphic card). NVIDIA packaged together these and some other tools and made them available for Jetson. That package is called JetPack and can be downloaded for free from NVIDIA's website.

JetPack Installer can:
  • flash Jetson board with Ubuntu OS
    • 32-bit Ubuntu 14.04 on Jetson TK1
    • 64-bit Ubuntu 16.04 on Jetson TX1
  • install all the Jetson Embedded Platform tools (on the Jetson)
  • install various tools on the host only; it is not necessary to have Jetson Developer Kit (TK1 or TX1 boards) in order to run these tools on PC

Installation Process

Prerequisites

We have to have:
  • Jetson TX1 (target)
    • HDMI cable - to connect Jetson board to monitor
    • Micro-USB to USB cable - to connect Jetson with PC
    • USB keyboard
    • USB mouse
  • PC or Linux VM (host). Host is required for running JetPack installer as this can't be run directly on the Jetson. Also, host needs to be running Ubuntu 14.04.
NOTE: I tried to use PC with Ubuntu 16.04 as host but installation of some packages failed. E.g. Installation of OpenCV package compiled for 14.04 (libopencv4tegra-repo_2.4.13-17-g5317135_amd64_ubuntu-14.04.deb) and also some CUDA dependencies. Don't waste time on experimenting, just follow the instructions and stick to Ubuntu 14.04 on the host. I used Ubuntu 14.04 running as VM on VirtualBox on my Window 10 machine.

Downloading JetPack

  • Fill in the online form in order to get membership in the NVIDIA Embedded Developer Program
  • Download JetPack Installer. At the time of writing the latest version is v2.3.1 and the installer file name is JetPack-L4T-2.3.1-linux-x64.run.
  • Create a new directory to store installation packages and place .run installer in that directory

Hardware Setup

Host (PC/VM)

  • Connected to the router (WiFi or LAN cable)

Jetson

  • Connected to the router (WiFi or LAN cable)
  • USB Keyboard and Mouse attached 
  • Connected to the monitor via HDMI cable

Jetson comes preflashed with Ubuntu Linux. If we turn on Jetson device for the first time, Terminal window appears with instructions how to install Nvidia Linux driver:

$ cd ${HOME}/NVIDIA-INSTALLER
$ sudo ./installer.sh



This is a prerequisite for UI to appear after reboot which can be triggered with:

$ sudo reboot

Running the Installer

Add execution permission to .run installer:

/opt/JetPack$ chmod +x JetPack-L4T-2.3.1-linux-x64.run

Run the installer:

/opt/JetPack$ ./JetPack-L4T-2.3.1-linux-x64.run


Installation Wizard appears:



Wizard shows Installation directory:



In the next step we have to select Jetson platform we'll be installing JetPack on. In our case, that's Jetson TX1:



At one point installation prompts for privileges elevation:



Wizard now displays a Component Manager with list of tools that can be installed on the host and the target:



This is the second part of the list - showing all packages that can be installed on the target:


Here is a short description of some available packages:

NVIDIA PerfKit is a comprehensive suite of performance tools to help debug and profile OpenGL and Direct3D applications.

NVIDIA VisionWorks toolkit is a software development package for computer vision (CV) and image processing.

NVIDIA TensorRT is a high performance neural network inference engine for production deployment of deep learning applications.

If we don't have Jetson Developer Kit (Jetson board) but want to install JetPack on the host only, we can simply change Action type from install to no action for item group "For Jetson TX1 64bit".

In the next step we have to accept Ts&Cs:



Before the installation starts a pop up appears asking us to be aware about what's going on, to monitor the process and act if required:



Installer first downloads packages selected for installation:



We are half way through - host packages have been installed!



Because we included flashing OS in the process, in the next step we have to select our setup regarding Jetson's Internet accesses. Two options are available:

  • Jetson connects to the same router as the host (making them both members of the same subnet)
  • Host acts as gateway through which Jetson gets access to the outer network and Internet
    • Installer in this case automatically sets routing table and DHCP server

I opted for more straightforward option and connected both host and target to the same router: PC via WiFi and Jetson via LAN cable:



If host has multiple network interfaces (adapters), we have to select the one which is connected to the same network (router) as Jetson. We can run ifconfig command in the Terminal to find the name of the interface. LAN IP addresses of host's and target's network interface have to show that they belong to the same network (both have to have IP addresses which start with e.g. 192.168.0).



Wizard is listing what will be its next actions so we can still decide to go back change them if necessary:



Still on the host machine, a Terminal window appears listing instructions how to connect Jetson with the host and how to put Jetson into Force USB Recovery Mode which is required for flushing OS:



If running host on a Virtual Machine, we'll have to enable its access to the USB device. In VirtualBox, after connecting PC and Jetson with USB cable, I ran lsusb command but USB device with name Nvidia Corp was not in the list but I could see it in VirtualBox's list of USB Devices:



All I had to do was to click on USB Settings and add desired USB device to the filter:





lsusb command now shows NVIDIA Corp USB device:



 The output which appears on the host during flushing OS onto target:



...more output...:



 The output which appears on the host when flushing OS onto target is completed:



Upon restarting the Jetson, host has to establish SSH tunnel with it through which it will push software tools selected in the Package Manager. Host first has to get target's IP address:



We have to manually enter Jetson's IP address and OS username and password (default credentials are ubuntu/ubuntu):



We can determine IP address of each device with ifconfig command and we can verify that they both belong to the same subnet. If using VirtualBox, make sure that Virtual Machine's adapter is in Network settings attached to Bridged Adapter instead of NAT (the default option).



Once transport channel is established, we can confirm the list of the next actions:



...and trigger pushing software from host to target starts by clicking on Next button:



Once all selected software packages are installed on Jetson, Wizard is giving us an option to remove all package installers from the host:


This completes JetPack installation. Yay!




APPENDIX A: Connecting Jetson to the Internet via Host 


If we choose the following networking setup:



...Installer displays which actions it will perform in order to make this connection possible:



I haven't tried this setup myself though.


APPENDIX B: OpenCV for Tegra on Ubuntu 14.04 Installation fails (Ubuntu 16.04 --> Jetson)

During JetPack Installation Ubuntu 16.04 --> Jetson, installation of OpenCV for Tegra package fails as JetPack tries to install package compiled for Ubuntu 14.04 on Ubuntu 16.04:



I tried to install it manually but without success:





I completed the installation by omitting OpenCV for Tegra installation:


This made my JetPack installation incomplete. This is one of the reasons why I decided to stick with the recommendation and use Ubuntu 14.04 on the host.


APPENDIX C: Installing CUDA fails (Ubuntu 16.04 --> Jetson)











APPENDIX D: VisionWorks Package Installation 

During JetPack installation (Ubuntu 14.04 VM --> Jetson) installation of VisionWorks package on the target initially failed:



I installed suggested packages manually by executing the following commands in Jetson's Terminal:

sudo apt-get install libvisionworks
sudo apt-get install libvisionworks-dev
sudo apt-get install libvisionworks-docs
sudo apt-get install libvisionworks-samples
sudo apt-get install libvisionworks-nvxio
sudo apt-get install libvisionworks-nvxio-dev

Once this was done, I re-ran JetPack installer again (sudo ./JetPack….run) and quickly got to the list of modules and actions where I selected only VisionWorks and its dependencies to be installed.

When I tried to install only VisionWorks, I got a message that additional packages have to be installed first:



...so I selected both VisionWorks and its dependencies:


This completed successfully and at that point I had all desired packages installed.



What was your experience with installing JetPack on Jetson TX1? Did you come across similar problems and how did you solve them?



References:

TK1 Specification
TX1 Specification
JetPack Installation Notes