The NVIDIA Jetson Nano Developer Kit is a small edge computer for AI development.
In this article, you'll learn how to get started with the Jetson Nano, including:
- Jetson Nano Overview
- Installing prerequisites and configuring your Python environment
- Installing deep learning libraries
- Compiling and installing Jetson Inference
- Running the Jetson Inference demos
The Jetson Nano Developer Kit packs a Quad-core ARM A57 CPU with a clock rate of 1.43GHz and 4GB of low-power DDR4 memory. For the connectors, it has 4x USB 3.0, 1xUSB2.0 Micro-B for powering with 5V, a HDMI and Display Port connector for connecting displays as well as one or two camera connectors that allow you to connect a Raspberry Pi Camera.
|CPU||Quad-core ARM A57 @ 1.43 GHz|
|Memory||4 GB 64-bit LPDDR4 25.6 GB/s|
|Storage||microSD (not included)|
|Video Encoder||4K @ 30 | 4x 1080p @ 30 | 9x 720p @ 30 (H.264/H.265)|
|Video Decoder||4K @ 60 | 2x 4K @ 30 | 8x 1080p @ 30 | 18x 720p @ 30 (H.264/H.265)|
|Camera||2x MIPI CSI-2 DPHY lanes|
|Connectivity||Gigabit Ethernet, M.2 Key E|
|Display||HDMI and display port|
|USB||4x USB 3.0, USB 2.0 Micro-B|
|Others||GPIO, I2C, I2S, SPI, UART|
|Mechanical||69 mm x 45 mm, 260-pin edge connector|
For further information and a comparison between the different Jetson devices, you can visit the Jetson Hardware section.
Besides the Jetson Nano Developer Kit you'll also need a microSD card, a power Supply (5V 2A), and an ethernet cable or WiFi adapter.
The Jetson Nano uses a microSD card as a boot device and primary storage. The minimum size for the microSD card is 16GB, but I would strongly recommend getting at least 32GB. It's also essential to get a fast microSD as this will make working on the Jetson Nano a lot more fluent.
The Jetson Nano is powered over USB Micro-B. The power supply needs to supply 5V 2A. Not every power supply is capable of providing this. NVIDIA specifically recommends a 5V 2.5A power supply from Adafruit, but I use a Raspberry Pi power supply and it works just fine.
Ethernet cable or WiFi Adapter
Lastly, you'll need an ethernet cable or a WiFi Adapter since the Jetson Nano doesn't come with one. For the WiFi Adapter, you can either use one that connects through USB, or you can use a PCIe WiFi Card like the Intel® Dual Band Wireless-AC 8265.
After that is done you need to insert the microSD card into the microSD slot as shown in the following image:
After inserting the microSD card, you can connect the power supply, which will automatically boot up the system.
When you boot the system for the first time, you'll be taken through some initial setup, including:
- Review and accept NVIDIA Jetson software EULA
- Select system language, keyboard layout, and time zone
- Create username, password, and computer name
- Log in
After the initial setup, you should see the following screen:
Installing prerequisites and configuring your Python environment
Now, that the Jetson Nano is ready to go we will go through creating a deep learning environment. We will start of by installing all prerequsites and configuring a Python environment as well as how to code remote using VSCode Remote SSH.
sudo apt-get update sudo apt-get upgrade sudo apt-get install git cmake python3-dev nano sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev
Configuring your Python environment
Next we will configure our Python environment. This includes downloading pip3 and virtualenv.
sudo apt-get install python3-pip sudo pip3 install -U pip testresources setuptools
For managing virtual environments we'll be using virtualenv, which can be installed like below:
sudo pip install virtualenv virtualenvwrapper
To get virtualenv to work we need to add the following lines to the ~/.bashrc file:
# virtualenv and virtualenvwrapper export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source /usr/local/bin/virtualenvwrapper.sh
To activate the changes the following command must be executed:
Now we can create a virtual environment using the mkvirtualenv command.
mkvirtualenv ml -p python3 workon ml
Coding remote with Visual Studio Code (optional)
If you are like me and hate writing long scripts in nano or vim, the VSCode remote development plugin is for you. It allows you to develop remotely inside VSCode by establishing an SSH remote connection.
To use VSCode remote development, you'll first have to install the remote development plugin. After that, you need to create an SSH-Key on your local machine and then copy it over to the Jetson Nano.
# Create Key ssh-keygen -t rsa # Copy key to jetson nano cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
Now you only need to add the SSH Host. Ctrl + Shift + P -> Remote SSH: Connect to Host.
Installing deep learning libraries
Now that we have our development and python environments set up, we can start installing some deep learning libraries. NVIDIA provides a guide on how to install deep learning libraries on the Jetson Nano. I simply put the commands for some installations below.
# install prerequisites $ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev # install and upgrade pip3 $ sudo apt-get install python3-pip $ sudo pip3 install -U pip testresources setuptools # install the following python packages $ sudo pip3 install -U numpy==1.16.1 future==0.17.1 mock==3.0.5 h5py==2.9.0 keras_preprocessing==1.0.5 keras_applications==1.0.8 gast==0.2.2 enum34 futures protobuf # to install TensorFlow 1.15: $ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 'tensorflow<2' # or install the latest version of TensorFlow (2.0) $ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow
# beforehand, install TensorFlow (https://eLinux.org/Jetson_Zoo#TensorFlow) $ sudo apt-get install -y build-essential libatlas-base-dev gfortran $ sudo pip3 install keras
# for PyTorch , install OpenBLAS and OpenMPI $ sudo apt-get install libopenblas-base libopenmpi-dev $ sudo pip3 install mpi4py # download whl $ wget https://nvidia.box.com/shared/static/3ibazbiwtkl181n95n9em3wtrca7tdzp.whl -O torch-1.5.0-cp36-cp36m-linux_aarch64.whl # Python 2.7 (download pip wheel from above) $ sudo pip install torch-1.5.0-cp36-cp36m-linux_aarch64.whl # Python 3.6 (download pip wheel from above) $ sudo pip3 install Cython $ sudo pip3 install numpy torch-1.5.0-cp36-cp36m-linux_aarch64.whl
Select the version of torchvision to download depending on the version of PyTorch that you have installed:
- PyTorch v1.0 - torchvision v0.2.2
- PyTorch v1.1 - torchvision v0.3.0
- PyTorch v1.2 - torchvision v0.4.0
- PyTorch v1.3 - torchvision v0.4.2
- PyTorch v1.4 - torchvision v0.5.0
- PyTorch v1.5 - torchvision v0.6.0
$ sudo apt-get install libjpeg-dev zlib1g-dev $ git clone --branch <version> https://github.com/pytorch/vision torchvision # see below for version of torchvision to download $ cd torchvision $ sudo python3 setup.py install $ cd ../ # attempting to load torchvision from build dir will result in import error $ sudo pip install 'pillow<7' # always needed for Python 2.7, not needed torchvision v0.5.0+ with Python 3.6
Compiling and installing Jetson Inference
NVIDIA's Jetson Inference repository includes lots of great scripts that allow you to perform image classification, object detection, and semantic segmentation on both images and a live video stream. In this article, we will go through how to compile and install the Jetson Inference repository and how to run some of the provided demos. Maybe I will go through the repository in more detail in an upcoming article.
To install Jetson Inference, you need to run the following commands:
# download the repo $ git clone https://github.com/dusty-nv/jetson-inference $ cd jetson-inference $ git submodule update --init # configure build tree $ mkdir build $ cd build $ cmake ../ # build and install $ make $ sudo make install $ sudo ldconfig
Running the Jetson Inference demos
After building the project, you can go to the jetson-inference/build/aarch64/bin directory. Inside you'll find multiple C++ and Python scripts. Below we'll go through how to run image classification, object detection, and semantic segmentation.
Inside the folder there are two imagenet examples. One for a image and one for a camera. Both are available in C++ and Python.
- imagenet-console.cpp (C++)
- imagenet-console.py (C++)
- imagenet-camera.cpp (C++)
- imagenet-camera.py (C++)
# C++ $ ./imagenet-console --network=resnet-18 images/jellyfish.jpg output_jellyfish.jpg # Python $ ./imagenet-console.py --network=resnet-18 images/jellyfish.jpg output_jellyfish.jpg
- detectnet-console.cpp (C++)
- detectnet-console.py (Python)
- detectnet-camera.cpp (C++)
- detectnet-camera.py (Python)
# C++ $ ./detectnet-console --network=ssd-mobilenet-v2 images/peds_0.jpg output.jpg # --network flag is optional # Python $ ./detectnet-console.py --network=ssd-mobilenet-v2 images/peds_0.jpg output.jpg # --network flag is optional
# C++ $ ./segnet-console --network=fcn-resnet18-cityscapes images/city_0.jpg output.jpg # Python $ ./segnet-console.py --network=fcn-resnet18-cityscapes images/city_0.jpg output.jpg
That's it from this article. In follow-up articles, I will go further into developing Artificial Intelligence on the Jetson Nano, including:
- Deploying custom models on the Jetson Nano
- NVIDIA Jetbot
If you have any questions or just want to chat with me, feel free to leave a comment below or contact me on social media. If you want to get continuous updates about my blog make sure to join my newsletter.