Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).

Docker 19.03 comes to NVIDIA Jetson Nano

6 min read

Did you know? In the latest Docker 19.03 Release, a new flag –gpus have been added for docker run which allows to specify GPU resources to be passed through to the Docker Image(NVIDIA GPUs). The latest nvidia-docker has already adopted this feature (see github), but deprecated --runtime=nvidia.

Last Dockercon, I met with a four-wheeled knee-high tiny cute food delivery robot called Kiwibot. Built by KiwiCampus Inc., Kiwibot is the robot counterpart of the pizza delivery person. Thanks to Dockercon for bringing this amazing piece of technology in-house for distributing swags, stickers, chocolates and goodies.

What’s so cool about Kiwibots?

Just open up your Wiki app and place an order for food. When you place an order online(facility to choose a participating restaurant), you get the option of delivery via Kiwi. Once you choose, one of the company’s fleet of super cool robots with insulated, locking storage compartments will swing by the place, your order is put within, and it brings it to your location. You can even watch the last bit live from the robot’s perspective as it rolls up to your place. Amazing, isn’t it?

Well, the super cute make and structure of these kiwibots looked interesting to me BUT what fascinated me really is the technology behind these small robots. A Kiwibot is equipped with six cameras and GPS to deliver the order at the right place. Nice ! Now here comes the best part. Only the person who has ordered will be able to open the Kiwibot and retrieve the order through the app which means it is intelligent enough to do object detection and analytics too. Interesting !!

Tell me more…

Source:https://www.kiwicampus.com/technology

I went through the technology stack and was really amazed to learn that it uses NVIDIA Jetson TX2 system for  all of the AI processing, imaging, and related computing tasks(see picture below). Jetson TX2 is a credit card-sized platform that puts AI computing to work in the world all around us. Obviously, GPU-based deep learning has given computers the ability to understand — and react to — the data streaming in from all these devices in uncanny new ways. Both through training — which creates smart systems — and through inference — which creates systems that are able to react intelligently to the world around them in real time.

Before I loose my patience any further, the day finally arrived when I was lucky enough to hold the most powerful AI platform in my hand.

The NVIDIA® Jetson Nano™ Developer Kit is purely an AI computer. It is a small, powerful computer that lets you run multiple neural networks 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 watts. It is perfect for makers, learners, and developers that brings the power of modern artificial intelligence to a low-power, easy-to-use platform.

Some Really Useful Facts around NVIDIA Jetson Nano..

  • There are 2 ways to power a Jetson Nano – either using Micro USB power supplies Or by using Barrel Jack 5V 4A(20W) power supplies. I don’t recommend using the normal micro-USB adapter which you use for mobile. Buy here if you are in India
  • Jetson Nano works in 2 model – MAXN and 5 Watt. By default the Nano works at MAXN(10 Watt mode). If using a Micro USB adapter you should change that immediately to 5W mode. When using the barrel jack to connect a 5V 4A (20W) power supply, you should set the Nano into 10 Watt mode to allow maximum power usage. Learn more
  • No WiFi module is shipped with this board. A user can easily get a wifi dongle or module that’s already been certified and plug it in for the usage
  • Jetson Nano is supported by the comprehensive NVIDIA® JetPack™ SDK, and has the performance and capabilities needed to run modern AI workloads. JetPack includes:
  • Jetson Nano comes with Full desktop Linux with NVIDIA driver, AI and Computer Vision libraries and APIs. developer tools & documentation and sample code.

Installing Docker 19.03 on NVIDIA Jetson Nano

Early this May 2019, I wrote a blog post around Docker 19.03 which comes with a new –gpus CLI plugin capability. With the recent 19.03 GA Release, now you don’t need to spend time in downloading the NVIDIA-DOCKER plugin and rely on nvidia-wrapper to launch GPU containers. All you can now use –gpus option with docker run CLI to allow containers to use GPU devices seamlessly.

As I wanted to try running CUDA containers on Jetson Nano, I couldn’t wait to update it to 19.03 release so as to see how containers can leverage the existing GPU device. Under this blog post, I will showcase how to get started with Docker 19.03 on Jetson Nano.

Preparing Jetson Nano

  • Unboxing Jetson Nano Pack
  • Preparing your microSD card

To prepare your microSD card, you’ll need a computer with Internet connection and the ability to read and write SD cards, either via a built-in SD card slot or adapter.

  1. Download the Jetson Nano Developer Kit SD Card Image, and note where it was saved on the computer.
  2. Write the image to your microSD card( atleast 16GB size) by following the instructions below according to the type of computer you are using: Windows, Mac, or Linux. If you are using Windows laptop, you can use SDFormatter software for formatting your microSD card and Win32DiskImager to flash Jetson Nano Image. In case you are using Mac, you will need Etcher software.
  1. To prepare your microSD card, you’ll need a computer with Internet connection and the ability to read and write SD cards, either via a built-in SD card slot or adapter

The Jetson Nano SD card image is of 12GB(uncompressed size).

Next, It’s time to remove this tiny SD card from SD card reader and plugin it to Jetson Board to let it boot.

Wow ! Jetson Nano comes with 18.09 by default

Yes, you read it correct. Let us try it once. First we will verify OS version running on Jetson Nano.

Verifying OS running on Jetson Nano

jetson@jetson-desktop:~$ sudo cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
jetson@jetson-desktop:~$

Verifying Docker

jetson@jetson-desktop:~$ sudo docker version
Client:
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        6247962
 Built:             Tue Feb 26 23:51:35 2019
 OS/Arch:           linux/arm64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       6247962
  Built:            Wed Feb 13 00:24:14 2019
  OS/Arch:          linux/arm64
  Experimental:     false
jetson@jetson-desktop:~$

Updating OS Repository

sudo apt update

Installing Docker 19.03 Binaries

You will need curl command to update Docker 18.09 to 19.03 flawlessly.

sudo apt install curl
curl -sSL https://get.docker.com/ | sh
jetson@jetson-desktop:~$ sudo docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:32:21 2019
 OS/Arch:           linux/arm64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:30:53 2019
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
jetson@jetson-desktop:~$

Installing Docker Compose

root@jetson-desktop:/home/jetson# /usr/bin/docker-compose version
docker-compose version 1.17.1, build unknown
docker-py version: 2.5.1
CPython version: 2.7.15+
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
root@jetson-desktop:/home/jetson#

Turn Your Jetson Nano into CCTV Camera

You can connect USB camera module directly into Jetson Nano camera slot and it should work flawlessly.

All you need to do is clone the below GITHUB repository and run the script.

git clone https://github.com/ajeetraina/docker-cctv-raspbian
cd docker-cctv-raspbian
sh run.sh

The script will pull the Docker Image from DockerHub and run the container to turn your Jetson Nano into CCTV camera.


root@jetson-desktop:~/docker-cctv-raspbian# docker ps
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS              PORTS                    NAMES
b6ff860d4f2a        ajeetraina/docker-cctv-raspbian   "motion"            6 seconds ago       Up 2 seconds        0.0.0.0:8081->8081/tcp   hopeful_newton
root@jetson-desktop:~/docker-cctv-raspbian#

Just one liner CLI and I was able to see my logitech webcam in action.(see below)

Figure: This image is captured by Logitech webcam mounted on Jetson Nano board

Running Hello World Example with Jetson Nano

jetson@jetson-desktop:~$ docker run arm64v8/hello-world
Unable to find image 'arm64v8/hello-world:latest' locally
latest: Pulling from arm64v8/hello-world
3b4173355427: Pull complete
Digest: sha256:5970f71561c8ff01d1d97782f37b0142315c53f31ad23c22883488e36a6dcbcb
Status: Downloaded newer image for arm64v8/hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

jetson@jetson-desktop:~$

Verifying NVIDIA Container Runtime

NVIDIA Container Runtime with Docker integration (via the nvidia-docker2 packages) is included as part of NVIDIA JetPack. It is available for install via the NVIDIA SDK Manager along with other JetPack components as shown below:

jetson@jetson-desktop:~$ sudo docker info | grep nvidia
 Runtimes: nvidia runc
jetson@jetson-desktop:~$ sudo dpkg --get-selections | grep nvidia
libnvidia-container-tools                       install
libnvidia-container0:arm64                      install
nvidia-container-runtime                        install
nvidia-container-runtime-hook                   install
nvidia-docker2                                  deinstall
nvidia-l4t-3d-core                              install
nvidia-l4t-apt-source                           install
nvidia-l4t-bootloader                           install
nvidia-l4t-camera                               install
nvidia-l4t-ccp-t210ref                          install
nvidia-l4t-configs                              install
nvidia-l4t-core                                 install
nvidia-l4t-cuda                                 install
nvidia-l4t-firmware                             install
nvidia-l4t-graphics-demos                       install
nvidia-l4t-gstreamer                            install
nvidia-l4t-init                                 install
nvidia-l4t-kernel                               install
nvidia-l4t-kernel-dtbs                          install
nvidia-l4t-kernel-headers                       install
nvidia-l4t-multimedia                           install
nvidia-l4t-multimedia-utils                     install
nvidia-l4t-oem-config                           install
nvidia-l4t-tools                                install
nvidia-l4t-wayland                              install
nvidia-l4t-weston                               install
nvidia-l4t-x11                                  install
nvidia-l4t-xusb-firmware                        install
jetson@jetson-desktop:~$

Running CUDA on Containers on Jetson Nano

jetson@jetson-desktop:~$ sudo docker run -it --runtime nvidia devicequery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA Tegra X1"
  CUDA Driver Version / Runtime Version          10.0 / 10.0
  CUDA Capability Major/Minor version number:    5.3
  Total amount of global memory:                 3956 MBytes 
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
....
  
  

What’s Next?

Integrating Pico – A Deep Learning Platform with Jetson & Docker is an exciting project I am working on. If you’re completely new, do check out
https://github.com/collabnix/pico for further details.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server
Index