NVIDIA driver installation on Ubuntu for computing workloads
Updated · Scientifically reviewed by Dinkar Mishra, PhD on
Short answer
On Ubuntu, install the driver from the distribution's packages: run sudo ubuntu-drivers install (or apt install a specific nvidia-driver-XXX or nvidia-driver-XXX-server package), reboot, and check with nvidia-smi. Install the CUDA toolkit separately only if you compile CUDA code; frameworks such as PyTorch ship their own CUDA runtime. On servers, use the -server driver branch, enable persistence, and hold the driver version to avoid surprise upgrades.
Who this is for
Researchers and administrators preparing Ubuntu workstations or servers with NVIDIA GPUs for CUDA, simulation codes and machine learning.
Software
Ubuntu 22.04 / 24.04 LTSNVIDIA driver production branch recommended by ubuntu-driversCUDA Toolkit 12.x (optional)
Prerequisites
- Ubuntu 22.04 or 24.04 LTS, fully updated (
sudo apt update && sudo apt full-upgrade), then rebooted. - The GPU visible on the PCIe bus:
lspci | grep -i nvidia. If it is not, see GPU not detected in Linux. - To know whether Secure Boot is enabled:
mokutil --sb-state.
Step 1: see the recommended drivers
sudo ubuntu-drivers list # on older releases: ubuntu-drivers devices
The output lists driver packages suitable for your GPU, with one marked as recommended.
Step 2: install the driver
Let Ubuntu choose (simplest):
sudo ubuntu-drivers install
sudo reboot
Or install a specific branch, for example on a headless compute server:
apt-cache search --names-only '^nvidia-driver-[0-9]+-server$'
sudo apt install nvidia-driver-550-server # pick a branch listed by the command above
sudo reboot
If Secure Boot is enabled, the installer asks you to set a password, and after reboot a blue “MOK management” screen asks for it to enrol the signing key. Choose Enroll MOK and enter the password; otherwise the driver will not load.
Step 3: CUDA toolkit (only if you compile CUDA code)
Install from NVIDIA’s repository so that you can choose the toolkit version. Follow the network-repository instructions for your Ubuntu release in the CUDA installation guide, then:
sudo apt install cuda-toolkit-12-6 # toolkit only; keeps your existing driver
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
Installing the cuda meta-package would also install NVIDIA’s driver and may replace the Ubuntu driver. Install cuda-toolkit-* when the driver is managed separately.
Step 4: server settings
sudo systemctl enable --now nvidia-persistenced # keeps the driver initialised between jobs
sudo apt-mark hold nvidia-driver-550-server # the exact driver package you installed
apt-mark showhold # confirm what is held
Systems with NVSwitch (for example 8-GPU HGX servers) also need the NVIDIA Fabric Manager package that matches the driver version. Without it, CUDA applications fail to start.
Verify
nvidia-smi # driver version, supported CUDA version, GPUs, memory
nvidia-smi -q | grep -i persistence
nvcc --version # only if you installed the toolkit
A quick functional test with a framework:
python3 -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
For performance checks, see how to benchmark GPU performance.
Troubleshooting
- nvidia-smi: “couldn’t communicate with the NVIDIA driver”: the module did not load. Check Secure Boot enrolment,
dkms statusfor the running kernel, andsudo dmesg | grep -i nvidia. - Black screen on a desktop after installation: boot into recovery mode, then purge and reinstall the recommended driver (
sudo apt purge '^nvidia-.*', thensudo ubuntu-drivers install). - Applications report an insufficient driver version: the application’s CUDA runtime is newer than your driver supports. Upgrade the driver branch, or use a build for an older CUDA version.
Assumptions and limitations
- Branch numbers in the examples are illustrative. Use the branches that
ubuntu-driversandapt-cache searchlist for your release. - Commands are for Ubuntu. RHEL-family systems use NVIDIA’s or ELRepo’s repositories with
dnf. - Data-centre GPUs in virtual machines (vGPU, MIG partitions) need additional configuration not covered here.
Frequently asked questions
Do I need the CUDA toolkit to run PyTorch or other GPU applications?+
No. Pre-built PyTorch, JAX and CuPy wheels include the CUDA runtime libraries they need; only the driver must be installed and new enough. You need the toolkit (nvcc, headers) to compile CUDA code yourself, for example to build WarpX or other simulation codes.
What is the difference between nvidia-driver-XXX and nvidia-driver-XXX-server?+
The -server packages follow NVIDIA's data-centre release branches with longer support, and are intended for headless compute servers. Desktop packages target workstations with displays. Both run CUDA workloads.
Should I use the .run installer from NVIDIA's website?+
Prefer packages. The .run installer bypasses the package manager, does not integrate with Secure Boot signing and must be reinstalled after kernel updates. Use it only if packages are not an option.
Which driver version do I need for my CUDA version?+
Each CUDA release requires a minimum driver version, listed in NVIDIA's CUDA release notes. nvidia-smi reports the highest CUDA version the installed driver supports.
References
Want this set up and verified for you?
We install, configure and validate scientific software on your workstation, cluster or cloud, and train your team to run it.
Services listed on this page are available today. Products marked “early access” or “in development” on our platform page are not yet generally available.
Spotted an error or an outdated command? Tell us. We correct verified issues promptly.