Skip to content

Nvidia

Updated by Hongjiang on 08/19/2023

nvidia-smi

Install:

ubuntu-drivers devices
# == /sys/devices/pci0000:80/0000:80:03.0/0000:82:00.0 ==
# modalias : pci:v000010DEd00001E87sv00001458sd000037A8bc03sc00i00
# vendor   : NVIDIA Corporation
# model    : TU104 [GeForce RTX 2080 Rev. A]
# driver   : nvidia-driver-450-server - distro non-free
# driver   : nvidia-driver-525-open - distro non-free
# driver   : nvidia-driver-515 - distro non-free
# driver   : nvidia-driver-530 - distro non-free
# driver   : nvidia-driver-525 - distro non-free
# driver   : nvidia-driver-515-server - distro non-free
# driver   : nvidia-driver-525-server - distro non-free
# driver   : nvidia-driver-515-open - distro non-free
# driver   : nvidia-driver-530-open - distro non-free recommended
# driver   : nvidia-driver-470 - distro non-free
# driver   : nvidia-driver-470-server - distro non-free
# driver   : nvidia-driver-510 - distro non-free
# driver   : nvidia-driver-418-server - distro non-free
# driver   : xserver-xorg-video-nouveau - distro free builtin
sudo apt install nvidia-driver-530

Reboot the system.

sudo reboot
watch -n 1 nvidia-smi

In Docker

docs.nvidia.com

Setup the package repository and the GPG key:

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit

Debug

In case you encount error like this:

E: Conflicting values set for option Signed-By regarding source https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64/ /: /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg != 
E: The list of sources could not be read.

From github issues Looking at the contents of your /etc/apt/sources.list.d/ directory I see multiple nvidia-.list file. If you look at their contents you should see multiple lines with the same URL. You should be able to delete the nvidia-container-runtime.list and nvidia-docker.list* files and only use the nvidia-container-toolkit.list file with the contents:

$ cat /etc/apt/sources.list.d/nvidia-container-toolkit.list
deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/$(ARCH) /