How to run docker image with Nvidia gpu on CachyOS with Nvidia open driver?

Hi,
I tried to run a docker image with gpu. However, I got this error:

docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].

I installed CachyOS with the default Nvidia open driver. nvidia-smi works on the terminal:

nvidia-smi
Sun Jan  5 12:36:35 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4060 ...    Off |   00000000:01:00.0  On |                  N/A |
| N/A   43C    P5              5W /   75W |     881MiB /   8188MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

I can reproduce the error by running this base nvidia docker image that also returns the same error:

docker run --rm --gpus all nvidia/cuda:12.6.3-base-ubuntu24.04 nvidia-smi

After reading some resources, I’ve fixed my problem.
In order use Nvidia in a docker container, I need the Nvidia Container Toolkit. It can works with the open-source NVidia driver.
These commands fix my issue:

sudo pacman -S nvidia-container-toolkit
sudo systemctl restart docker
1 Like