📢 Free and Open source computer vision API based on open source models 🚀
Support multiple deep learning frameworks as well as multiple hardware accelerators
Discover more here 👇
Last update: 07 June 2021
This article will guide you step by step to create a minimalist Ubuntu based image for your NVIDIA Jetson nano board that best suits your project.
First, for fun. It's always interesting to build stuff from scratch as you always learn something in the process. Second, the official image is large in size (over 5GB 😱 ) and it's filled with lot of unnecessary preinstalled packages (ubuntu-desktop, browser ...) that takes lot of disk space and memory. So, let's create a clean and minimalist image.
Before starting, let's first clone the repository where I put all the needed scripts.
$ git clone https://github.com/pythops/jetson-nano-image $ cd jetson-nano-image
We're gonna use the script
create-rootfs.sh to create a basic rootfs.
First, we define the location where we want to build it. This is done by defining the environment variable
$JETSON_ROOTFS_DIR. The path will be created if it does not exit.
$ export JETSON_ROOTFS_DIR=/path/to/rootfs
Then we build the rootfs by running the following command
$ sudo -E ./create-rootfs.sh ROOTFS_DIR: ~/jetson-rootfs Installing the dependencies... [OK] Creating rootfs directory... [OK] Downloading the base image... [OK] Run debootstrap first stage... [OK] Run debootstrap second stage... [OK] Success!
-E option for sudo preserve the environment variables
Now that we have a basic rootfs, we're gonna customize it using one of my favorite tool ever:
For this step you need to have Ansible installed in your workstation. if it's not the case, just run this command and you're ready to go
$ pip install --user ansible
This Ansible role is going to do 3 things: * Install some basic tools (ssh, systemd, sudo ...) * Setup basic configurations (locales, network ...) * Add new user: pythops
You can run the playbook as follows
$ cd ansible $ sudo -E $(which ansible-playbook) jetson.yaml
Feel free to adapt this role to your needs.
Now that we customized the rootfs, we're gonna use the script
create-image.sh to create our final image.
Before we build the image, you need to define the type of your board. Currently, the supported boards are Jetson Nano and Jetson Nano 2GB.
To define the type of your board, you need to set an enviroment variable called
$JETSON_NANO_BOARD as following:
For the Jetson nano board
For the Jetson Nano board 2GB
For Jetson nano board 4GB only, you can specify which board model you wanna use
A02 model. If you buy a new board now, chances are you're gonna get the
To specify your model, you need to define a new enviroment variable
$JETSON_NANO_REVISION as following:
B01 model (the default):
$ export JETSON_NANO_REVISION=300
$ export JETSON_NANO_REVISION=200
We need to define a build directory as well using the enviroment variable
$JETSON_BUILD_DIR. This path will be created if it does not exist.
$ export JETSON_BUILD_DIR=/path/to/build_dir
Then we build the image as follows
$ sudo -E ./create-image.sh
If all goes well, you'll get this message at the end
Image created successfully Image location: /path/to/jetson.img
Finally we're gonna flash the image on the sdcard using the script
Insert your sdcard and run this command
$ sudo ./flash-image.sh /path/to/jetson.img /dev/mmcblk0 . . . Success ! Your sdcard is ready !
the sdcard path /dev/mmcblk0 may be different in your system.
This script will automatically resize the root partition to occupy all the available space in the sdcard.
Congratulations 🎉 Now you can boot your board with the new image !
You can install Nvidia libraries using
$ sudo apt install -y cuda-toolkit-10-2 libcudnn8 libcudnn8-dev
With the new image only 200MB of RAM is used, which leaves you with 3.8 GB for your projects !