GPU containers
Run CUDA and local models in a container. On the NVIDIA image, podman gives a container the GPU
with --device nvidia.com/gpu=all.
Give a container the GPU
If this prints your card, it works:
podman run --rm --device nvidia.com/gpu=all registry.fedoraproject.org/fedora nvidia-smi
For example, ollama:
podman run -d --device nvidia.com/gpu=all docker.io/ollama/ollama
The driver and libcuda come from the image, and the container brings its own CUDA
runtime. The same thing as a quadlet:
[Container]
Image=docker.io/ollama/ollama
AddDevice=nvidia.com/gpu=all
NVIDIA image only. On the standard image, pass /dev/dri for Vulkan.
What makes it work
Podman uses CDI specs, which map nvidia.com/gpu=all to device nodes and driver
libraries. Two units set this up at each boot.
-
nvidia-cdi-refresh.servicewrites the spec for the running driver to/var/run/cdi/nvidia.yaml. That folder is a tmpfs, emptied at every shutdown. -
pulsar-gpu-containers.serviceturns on the SELinux booleancontainer_use_xserver_deviceseach boot. Without it,nvidia-smifails with “Failed to initialize NVML: Insufficient Permissions”. The boolean lets a container use a GPU device node it was given, and a container started without--devicehas no/dev/nvidia0to open.
Don’t write your own spec to /etc/cdi
nvidia-ctk cdi generate in /etc/cdi survives driver
updates and goes stale.
What doctor reports
$ pulsar doctor gpu-containers
ok gpu-containers CDI spec matches driver 615.71.09
podman run --rm --device nvidia.com/gpu=all IMAGE
| doctor says | Do this |
|---|---|
| no CDI spec, so containers cannot be given the GPU | sudo systemctl restart nvidia-cdi-refresh.service, then read journalctl -b -u nvidia-cdi-refresh.service |
| stale CDI spec for driver … | If the spec it names is in /etc/cdi, delete it. A hand-written spec there goes stale at every driver update. If it is in /var/run/cdi, run sudo systemctl restart nvidia-cdi-refresh.service, which writes that folder. |
| CDI spec matches …, but SELinux blocks containers from the GPU | The unit that turns the boolean on didn’t run. Look at systemctl status pulsar-gpu-containers.service. |
If no NVIDIA module is loaded at all, see the nvidia check in
Troubleshooting.
A model for your agents
pulsar agent model on runs llama.cpp’s server as a rootless quadlet (CUDA, Vulkan
or CPU) on 127.0.0.1 behind a key, for opencode. See
Coding agents.
Written with help from AI and reviewed by a person before publishing. If you find a mistake, open an issue on GitHub.