Last Updated: 2021-06-27
Tested on Fedora 34 (5.12.12-300.fc34.x86_64
)
First, add the RPM Fusion repositories:
sudo dnf update
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Next, install the drivers. You can use this tool to look up the version you need. If you don't know which GPU do you have, you can run lspci -vnn | grep VGA
.
sudo dnf install xorg-x11-drv-nvidia-cuda akmod-nvidia # 400 or higher
sudo dnf install xorg-x11-drv-nvidia-390xx akmod-nvidia-390xx
sudo dnf install xorg-x11-drv-nvidia-340xx akmod-nvidia-340xx
Add the NVIDIA repos:
curl -s -L https://nvidia.github.io/nvidia-docker/centos8/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
# If you version of Fedora is based on RHEL 7 (or if it's older than Fedora 28), replace `centos8` by `centos7`
Install nvidia-docker
:
sudo dnf clean expire-cache --refresh
sudo dnf install -y nvidia-docker2
Disable cgroups:
# /etc/nvidia-container-runtime/config.toml
[nvidia-container-cli]
no-cgroups = true
Restart Docker and test:
sudo systemctl restart docker
sudo docker run --rm --gpus all --privileged nvidia/cuda:11.3.1-base nvidia-smi
You should get an output like this:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.31 Driver Version: 465.31 CUDA Version: 11.3 |
|-------------------------------+----------------------+----------------------+
| 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 ... Off | 00000000:26:00.0 On | N/A |
| 0% 44C P8 11W / 160W | 496MiB / 5931MiB | 3% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
If you want to use your NVIDIA GPU in a Docker container, you need to add the flags --gpus all
and --privileged
.
References: