1. Check the GPU and Update
lspci | grep -i nvidia # the card should be listed sudo apt update && sudo apt upgrade sudo reboot
Rebooting after the upgrade means the driver is built for the kernel you will actually run. This guide uses Ubuntu 24.04; the same steps work on 22.04.
2. Install the Driver
sudo ubuntu-drivers list --gpgpu # e.g. nvidia-driver-570-server, nvidia-driver-570-server-open sudo ubuntu-drivers install --gpgpu # the recommended one # or a specific branch from the list: # sudo ubuntu-drivers install --gpgpu nvidia:570-server sudo apt install -y nvidia-utils-570-server # nvidia-smi, same branch number sudo reboot
Replace 570 with the branch the list shows for your card. The -open variants use NVIDIA's open kernel modules, which NVIDIA recommends for recent GPUs.
3. Check It Works
nvidia-smi cat /proc/driver/nvidia/version
nvidia-smi lists every GPU with its memory, temperature, power and the processes using it, and shows the newest CUDA version the driver supports. watch -n 1 nvidia-smi keeps it updating while a job runs.
4. GPUs in Docker Containers
With Docker installed, add NVIDIA's repository and the Container Toolkit, then let Docker use it:
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/stable/deb/nvidia-container-toolkit.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-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker # edits /etc/docker/daemon.json
sudo systemctl restart docker
sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smiThe last command should print the same table as on the host. In Compose files, give a service the GPUs with a deploy.resources.reservations.devices entry for the nvidia driver.
When Something Is Wrong
| Message | Usual cause | Fix |
|---|---|---|
| Driver/library version mismatch | An update replaced the driver while the old module is loaded | Reboot |
| NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver | The module is not loaded, often right after install | Reboot; then check sudo dmesg | grep -i nvidia |
| No devices were found | The driver does not support the card, or the card is not seen | Check lspci, try the newest -server branch, reboot |
| nouveau in lsmod | grep nouveau | The open-source driver grabbed the card | Install through ubuntu-drivers, which blacklists it, and reboot |
Next: how much GPU memory a model needs, and serving an LLM API with vLLM or Ollama.