5 steps to implement deep learning on Jetson Nano

Hi, I hope you enjoy your working day. If you have a Jetson Nano board and wanna build something new, this blog post is really for you. 

NVIDIA Jetson Nano Developer Kit is an embedded board that lets you run some deep learning algorithms in parallel for applications like image classification, object detection, segmentation, and speech processing. All in an easy-to-use platform that runs in as little as 5 volts. Today I will show you how to install the required system packages and prerequisites.

This tutorial follows the step-by-step document below:


If you are a beginner, I suggest you follow my tutorial. Your OS maybe has some conflicted libraries if you follow the original NVIDIA document. Additionally, I will introduce to you some machine performance monitoring tools in this article. Let's start it.

Installing Ubuntu Operating System

At first, I recommend using an SD card with a capacity larger than 16 GB. Otherwise, consider buying an SD card with a larger storage capacity (at least 32 GB).

You can follow (https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit) this complete step-by-step guide for installing OS on your NVIDIA Jetson Nano Developer Kit. But it is important to note that instead of installing the default operating system, you must install the package that includes CUDA-X accelerated libraries. This package is called JETPACK. The current version of JETPACK is JETPACK 4.6.1, However, you should install the package JETPACK 4.4.1 for stable operation.

Download the SD card image for JETPACK 4.4.1 at: https://developer.nvidia.com/jetpack-sdk-441-archive

If you have ever used a Raspberry Pi, you will be very disappointed to find out that the NVIDIA Jetson Nano Developer Kit does not have an onboard wifi card. That means you have to prepare an ethernet cable or buy an additional wifi card for the NVIDIA Jetson Nano Developer Kit and plugin before installing OS. The good news is that the wifi card extension is available on NVIDIA Jetson Nano Developer Kit.

After installing Operating System, you can see your desktop as below. If you installed it correctly, the folder L4T-README is available on your desktop.

Prerequisites and Dependencies

Follow this step-by-step guide to install prerequisites and dependencies libraries.

1. Update your system first.
sudo apt-get update

2. Install pip Package.
sudo apt-get install python3-pip

3. Install some necessary packages.
sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev
sudo apt-get install zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran

4. Install some prerequisites packages for tensorflow.
sudo pip3 install -U pip testresources setuptools
sudo pip3 install -U numpy==1.16.1 future==0.17.1 mock==3.0.5 h5py==2.9.0
sudo pip3 install -U pip keras_preprocessing==1.0.5 keras_applications==1.0.8
sudo pip3 install -U gast==0.2.2 futures protobuf pybind11

5. Install tensorflow 1.15.0 (GPU available)
sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v441 'tensorflow<2'
If you wanna install other version, issue the following command.
sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v441 tensorflow==$TF_VERSION
Example for installing tensorflow 2.4.0
sudo pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v441 'tensorflow==2.4.0+nv21.5'

Verifying the installation

To verify that tensorflow has been successfully installed on Jetson Nano Developer Kit, you’ll need to command like below.
python3 -c 'import tensorflow as tf; print(tf.__version__)'
The output will be your installed version of tensorflow.

Make your terminal amazing

You can customize your terminal startup skin with some command-line arguments. If you wonder how the Ubuntu logo can be displayed on your terminal. The following command allows you to launch this one.

You can make the same thing by command.
sudo apt-get install neofetch

This Ubuntu logo can be displayed automatically when you open the terminal. To do this, you have to add something at the bottom of ~/.bashrc
sudo apt-get install nano
nano ~/.bashrc

Add "Neofetch" at the bottom. Maybe you need restarting to apply a new setting.

Installing system-monitor

It is necessary for tracking the list of the processes running on a computer. The application can show you any update of the CPU, GPU, memory usage during training the model. With popular Ubuntu OS, we are usually using the htop library. Unfortunately, in Jetson Nano Developer Kit we cannot do this. However, we can use another library named jtop for handling this task. You can install jtop by this command.
sudo -H pip install -U jetson-stats

For tracking your system, let’s see about this command in detail below.

Try training something

After install finished, we can train a sample model to verify that working well. In this case, I will work on the MNIST dataset. Before following this part, confirm that your Jetson Nano Developer Kit installed the git library. If you have not installed yet, install it.
sudo apt-get install git

Clone Tensorflow GPU test source code from github via link https://github.com/redsriracha/tensorflow-gpu-test or pull it via git with command.
git clone https://github.com/redsriracha/tensorflow-gpu-test 

Enter your download folder and open run.py
cd tensorflow-gpu-test
python3 run.py
Enjoy your efforts.

Many thank Ngoc Truc for supporting me finish this tutorial.