Installing NVIDIA software
The steps below will install NVIDIA software components, specifically:
- NVIDIA GPU driver
- NVIDIA docker runtime
1. Add the NVIDIA package repository
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
2. Install the NVIDIA driver
sudo apt install -y nvidia-driver-550
3. Reboot the system to load the new driver
sudo reboot
4. Verify the driver installation
nvidia-smi
Example Output
Sun May 26 11:11:33 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.15 Driver Version: 550.54.15 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| 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 3070 ... Off | 00000000:01:00.0 Off | N/A |
| N/A 49C P0 N/A / 80W | 8MiB / 8192MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 1595 G /usr/lib/xorg/Xorg 4MiB |
+-----------------------------------------------------------------------------------------+
5. Add the NVIDIA Docker repository GPG key and repository
distribution=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -fsSL https://nvidia.github.io/nvidia-docker/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-docker-keyring.gpg
6. Add the NVIDIA repositories
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nvidia-docker-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 /" | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nvidia-docker-keyring.gpg] https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 /" | sudo tee -a /etc/apt/sources.list.d/nvidia-container-toolkit.list
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nvidia-docker-keyring.gpg] https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 /" | sudo tee -a /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
7. Install the NVIDIA Docker runtime
sudo apt install -y nvidia-docker2
sudo systemctl restart docker
8. Test the installation
Run the following command to test the NVIDIA installation. Note that it may take some time to download the docker image.
docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
Example Output
Mon Jun 24 12:57:08 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.86.10 Driver Version: 535.86.10 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| 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 3070 ... On | 00000000:01:00.0 Off | N/A |
| N/A 50C P0 24W / 80W | 10MiB / 8192MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
+---------------------------------------------------------------------------------------+