The NVIDIA GPU Container Runtime is a plugin that enables container platforms to securely access and manage NVIDIA GPUs as part of a containerized application environment. Docker is an open-source platform that automates the deployment, scaling, and management of applications within lightweight, portable containers. Podman is an open-source, daemonless container engine designed for developing, managing, and running OCI Containers, functioning as a drop-in replacement for Docker. This post contains the setup instructions for NVIDIA GPU container toolkits on Linux hosts running Ubuntu 22.04 for use with docker and podman.
The NVIDIA GPU Container Runtime is a plugin that enables container platforms to securely access and manage NVIDIA GPUs as part of a containerized application environment.
Docker is an open-source platform that automates the deployment, scaling, and management of applications within lightweight, portable containers.
Podman is an open-source, daemonless container engine designed for developing, managing, and running OCI Containers, functioning as a drop-in replacement for Docker.
Instructions for a Linux host running Ubuntu 22.04 to install the nvidia runtime for docker and podman.
We note that NVIDIA’s Container Toolkit officially only supports Ubuntu LTS release, but see this if your system is a 23.04 for example.
Preamble
The following are only required if you do not already have some of the tools installed.
Confirming the nvidia driver is available
The rest of this guide expects an already functional nvidia-driver.
To install it :
On Ubuntu Desktop, install from Software & Updates’s Additional Drivers and reboot.
On Ubuntu Server, confirm the device is available using ubuntu-drivers devices and install the recommended “server” driver: sudo apt install nvidia-driver-535-server, then reboot.
To confirm it is functional, after a reboot, run nvidia-smi from a terminal; if a valid prompt shows up, you will have information on the Driver Version and the supported CUDA Version for future running GPU-enabled containers.
You will need to log out entirely before the changes take effect. Once this is done, you should be able to run docker run hello-world without the need for a sudo:
sudo usermod -aG docker $USER
Install podman (> 4.1.0) on Ubuntu 22.04
On Ubuntu 22.04, apt search podman returns version 3 of podman. We need a version of podman above 4.1.0 to use the Container Device Interface (CDI) for nvidia-container-toolkit.
We recommend using Homebrew to get a more recent version of podman.
As you can see, at the time of this write-up, we have version 4.9.3, which is above the minimum 4.1.0 required to use the CDI.
In the Caveats section of the installation, it is recommended to brew services start podman to have podman run as a service now and after reboot, which we want. We recommend you run this command.
After doing so, we can check that which podman points us to /home/linuxbrew/.linuxbrew/bin/podman.
For podman to be functional, we still need to install newuidmap for “rootless mode” (Linux-native “fake root” for rootless containers) by
sudo apt install rootlesskit
Now we can test podman:
podman run hello-world
podman runs similarly to docker; for example:
podman run --rm -it ubuntu:22.04 /bin/bash
will download ubuntu:22.04, give you a bash shell prompt in an interactive session, and will delete the created container when you exit the shell.
We note that podman has a /home/linuxbrew/.linuxbrew/etc/containers/registries.conf file already configured with unqualified-search-registries=["docker.io"]. More details on that topic at https://podman.io/docs/installation#registriesconf.
Confirm docker (no sudo needed if you made the optional step in the last section) sees any GPU that you have running on your system by having it run nvidia-smi. Note that docker will need both --runtime=nvidia and --gpus all to use the proper runtime and have access to all the GPUs
docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
You can inspect your /etc/docker/daemon.json file to see that the nvidia-container-runtime is added:
To make this runtime the default, add the following content to the top of the file "default-runtime": "nvidia", (after the first {) and sudo systemctl restart docker. You should not have to add --runtime=nvidia to the CLI anymore.
Docker has become a cornerstone of the modern development stack: how applications are built, shipped, and run. It is an excellent solution to the portability problem: containers run consistently on any machine, eliminating the "it works on my machine" problem. It leverages containers: self-contained units of software that package the components needed for an application to run. This primer introduces its core concepts.
Kolla Ansible provides production-ready containers (here Docker) and deployment tools for operating OpenStack clouds. This guide explains how to install a single host (all-in-one) OpenStack Cloud on a Ubuntu 22.04 server Linux Operating System on a private network. We specify values and variables early that can easily be adapted to others’ networks. We do not address encryption for the different OpenStack services and will use an HTTPS reverse proxy for access to the dashboard. Please note that this setup requires two physical NICs in the computer you will use.