Skip to content

Instantly share code, notes, and snippets.

@gpshead
Last active June 26, 2024 06:45
Show Gist options
  • Save gpshead/0c3a9e0a7b3e180d108b6f4aef59bc19 to your computer and use it in GitHub Desktop.
Save gpshead/0c3a9e0a7b3e180d108b6f4aef59bc19 to your computer and use it in GitHub Desktop.
Build a Linux 4 Tegra with CUDA Ubuntu 22.04 docker image for the nVidia Jetson Nano using its final JetPak 4.6.3
# Make an Ubuntu 22.04 Docker image supporting CUDA and Linux 4 Tegra stuff on
# the nVidia Jetson Nano. I ran this from the final nano Linux 4 Tegra JetPak
# image aka jetson-nano-jp461-sd-card-image.zip which I updated to 4.6.3
# using apt. -- @gpshead
#
# Is there any real point to doing this? I have no idea. :P
# If you don't care about toying with the GPU stuff, just go install Armbian.
#
# This is based off of the instructions on
# https://github.com/NVIDIA/nvidia-docker/wiki/NVIDIA-Container-Runtime-on-Jetson
# and the final Jetpak 32.x container that represents the final Jetson Nano
# platform from https://catalog.ngc.nvidia.com/orgs/nvidia/containers/l4t-base
# before nvidia went ass-hole and abandoned three generations of hardware that
# they still ship.
FROM nvcr.io/nvidia/l4t-base:r32.7.1
RUN apt-get update && apt-get upgrade -y
RUN apt-get install ubuntu-release-upgrader-core -y --no-install-recommends
# 18.04 -> 20.04
RUN do-release-upgrade -f DistUpgradeViewNonInteractive
RUN apt-get update && apt-get upgrade -y
RUN apt-get clean
RUN apt-get install -y --no-install-recommends vim
# 20.04 -> 22.04 and IGNORE the error (which should be from usrmerge.postinstall)
RUN do-release-upgrade -f DistUpgradeViewNonInteractive ; exit 0
# Patch the failed convert-usrmerge to work around https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008202
RUN sed -i -e 's/no autodie;/rm(\"-rf\", \"$dir\");/g' -e 's/not rename/0 \&\& not rename/g' /usr/lib/usrmerge/convert-usrmerge
# Continue the last bit do-release-upgrade failed to do? (is this really enough?)
RUN dpkg --configure -a
RUN apt-get remove python2 -y
RUN apt-get autoremove -y
RUN apt-get clean
# All done here, the rest just proves that this 22.04 container supports CUDA.
# You MUST pass the `--runtime nvidia` flag to `docker run` for CUDA to work.
RUN apt-get install -y --no-install-recommends make g++
COPY ./samples /tmp/samples
WORKDIR /tmp/samples/1_Utilities/deviceQuery
RUN make clean && make
CMD ["./deviceQuery"]
@gpshead
Copy link
Author

gpshead commented Apr 9, 2023

Realistically this image is huge and contains all of the jetpak gui desktop software mega-bloat that nobody ever wants. If you have a specific use for this, at least make some of the first steps minimize the image before any upgrades.

@brianlmerritt
Copy link

Starting to run through this - if anyone else is following this, on installed clean image of jetpack 4.6.3, after running sudo apt update && sudo apt upgrade -y, the command sudo apt install nvidia-jetpack is likely to fail. The fix for that is:

sudo apt dist-upgrade
sudo apt update
sudo apt-get install nvidia-container
sudo apt-get install nvidia-jetpack

@KalanaRatnayake
Copy link

Hey guys!

Thanks for the suggestions. based on this, i upgraded the kernal of nvidia's r32.7.1 docker container and created a new base container with ubuntu focal 20.04. Tried to push it up to ubuntu 22.04 jammy but didnt proceed as it drops support for gcc8 and g++8 which is needed by cuda10.2 in jetson nano.

docker files and terminal commands are here https://github.com/KalanaRatnayake/jetson-docker

At the moment i provide a base container (822 MB) and a test container that is built on top of it (1.11GB) so that sizes stay low.

Will keep adding new images that extend the use cases of this

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