There does not appear to be any documentation on getting Nvidia support added to Docker or other container run times on Fedora 36, and it appears that Nvidia does not officially support Fedora with libnvidia-container repositories. I looked into this and found a solution to get Nvidia to work with Docker.

Install Docker Community Edition

The first step is to install the community edition of Docker as that is what nvidia-docker2 works with. Luckily Docker does have official support for Fedora, so it is simply running the following to get docker-ce installed.

sudo tee /etc/yum.repos.d/docker-ce.repo <<EOF
[docker-ce-stable]
name=Docker CE Stable - \$basearch
baseurl=https://download.docker.com/linux/fedora/36/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/fedora/gpg
EOF
dnf makecache
dnf install -y docker-ce

Install nvidia-docker2

Now that you have docker-ce installed, the final step is to install the nvidia-docker2 package from Nvidia's RHEL 9 repository.

DIST="rhel9.0"
curl -s -L https://nvidia.github.io/libnvidia-container/$DIST/libnvidia-container.repo | \
  sudo tee /etc/yum.repos.d/libnvidia-container.repo
dnf makecache
dnf install -y nvidia-docker2
systemctl restart docker

Testing

Now that it is installed, we can test it with the following.

docker run --rm --gpus all nvidia/cuda:11.7.1-runtime-ubuntu22.04 nvidia-smi

Remove nvidia/cuda with the following.

docker rmi nvidia/cuda:11.7.1-runtime-ubuntu22.04

Previous Post Next Post