Skip to content

Instantly share code, notes, and snippets.

@protosam
Last active January 4, 2024 19:59
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save protosam/48370bca14eeebca03b7cfe2ea042ef8 to your computer and use it in GitHub Desktop.
Save protosam/48370bca14eeebca03b7cfe2ea042ef8 to your computer and use it in GitHub Desktop.
Nvidia Jetson sdkmanager in Docker Notes

It seems appears that nVidia has container images for Docker with Ubuntu 18.04 that can be found here: https://developer.nvidia.com/nvidia-sdk-manager

They claim it's usable with just docker run -it --rm sdkmanager, but that is wrong. Also the use of bash is because the storage is ephemeral. Nothing worse than losing your progress between runs. It's also named while you're running so you can make commits if you need.

Anyways, after loading their image as described use the container like this:

$ docker run -it --rm --name=sdkmanager --rm=true --net=host --ipc host --privileged --cap-add SYS_ADMIN --volume="/dev/bus/usb:/dev/bus/usb" --entrypoint bash sdkmanager

Will update for Ubuntu 20.04 LTS support eventually.

Also they have useful docs: https://docs.nvidia.com/sdk-manager/docker-containers/index.html

Nvidia Jetson SDK Manager in Docker

The goal of this document is to aid in setting up a docker container that can flash Nvidia Jetson devices.

Additional Nvidia resources and documentation can be found here.

Prep-Work

On the host system, we need some modules loaded into the kernel that our container will need to work. It's best to use a debian based distro for our contianer to simplify things. My end goal was just to not be running things on a system that was released in 2016. So I did this on Ubuntu 20.04lts.

apt install -y binfmt-support qemu-user-static

We're also assuming you already have docker installed, but if you don't, here's how to install docker on Ubuntu.

apt install docker.io

Get the SDK Manager

The sdkmanager can be downloaded here.

You want to download the sdkmanager debian package to the host system and the provided Dockerfile in the same directory. You want to replace sdkmanager_1.3.1-7110_amd64.deb in the Dockerfile with the current .deb file name.

This file will end up being used inside the container image when we build it.

Build the Container Image

With our Dockerfile and sdkmanager_*_amd64.deb file in the same directory. We will run this command to build the image. It will take a while.

docker build -t jetpack-sdk .

If the build was successful, you'll see a tagged image called jetpack-sdk.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jetpack-sdk         latest              81ac43286fa0        41 hours ago        1.36GB

If it failed, we will have an untagged image and need to go figure out why:

<none>              <none>              349c7116b0a9        42 hours ago        1.36GB

Using the Image

The way I've been using this is completely manual. The provided Dockerfile is setup to launch a shell for running sdkmanager commands. However if you want to do automation type stuff, everything you need is inside the container and you can spend some time learning the in's and out's of docker to figure that out here.

To launch the container with neccessary permissions, here's the neccessary docker run command.

docker run -it --rm --name=jetpack-sdk --rm=true --net=host --ipc host --privileged --cap-add SYS_ADMIN --volume="/dev/bus/usb:/dev/bus/usb" jetpack-sdk

You will be placed inside a bash shell where you have the entire SDK at your disposal. You can run sdkmanager commands, or if you want to use build tools and make your own images, that can be done in the container too with some work to setup any additional build tools.

If you're using the sdkmanager, if can be used to help you stage commands. The flag --staylogin true is recommended to be added to commands so you don't have keep logging into the Nvidia site during a session. Upon running sdkmanager commands, you will have to click the Nvidia link to open a browser and login.

sdkmanager --cli install --logintype devzone --staylogin true --query interactive

An example command that I built from using the interactive mode:

sdkmanager --cli install  --logintype devzone --staylogin true --product Jetson --host --target P2888-0004 --targetos Linux --version 4.4.1 --flash all --license accept

Something to note, the provided command it gave me was P2888-0001, but upon reviewing the sdkmanager logs in ~/.nvsdk in the container, I found that my target device was actually supposed to be P2888-0004.

FROM ubuntu:18.04
# Install SDK deps
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
libgconf-2-4 \
libcanberra-gtk-module \
locales \
netcat \
openssh-server \
usbutils \
libgtk-3-0 \
libx11-xcb-dev \
libxss-dev \
libnss3 \
libcanberra-gtk-module \
libcanberra-gtk3-module \
nodejs \
firefox \
npm \
qemu-user-static \
apt-utils \
tzdata \
kmod \
sudo \
iproute2
RUN dpkg-reconfigure --frontend noninteractive tzdata
COPY sdkmanager_1.3.1-7110_amd64.deb /
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y /sdkmanager_1.3.1-7110_amd64.deb
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /
ENTRYPOINT [ "/bin/bash" ]
@jw-song
Copy link

jw-song commented Nov 15, 2023

I'm newer in jetson development. It's very helpful. that's cool.

@protosam
Copy link
Author

Glad it was helpful. Let me know if you run into any issues, I've not messed with my nVidia Xavier since last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment