Skip to content

How to Install NVIDIA Drivers on Ubuntu

How to Install NVIDIA Drivers on Ubuntu

NVIDIA drivers provide GPU acceleration for gaming, 3D rendering, CUDA computing, and machine learning. This guide covers multiple installation methods for Ubuntu Linux.


Prerequisites

  • Ubuntu 20.04+ / 22.04 / 24.04 / 26.04
  • Root or sudo access
  • NVIDIA GPU (GeForce, Quadro, Tesla, etc.)
  • Internet connection
  • Secure Boot disabled or MOK enrollment ready
Note: If Secure Boot is enabled, you’ll need to enroll a Machine Owner Key (MOK) during installation. A reboot will prompt you for this.

Method 1: ubuntu-drivers (Recommended)

Step 1: Update System

sudo apt update && sudo apt upgrade -y

Step 2: List Available Drivers

ubuntu-drivers devices

Look for “recommended” driver (e.g., nvidia-driver-595).

Step 3: Install Recommended Driver

sudo ubuntu-drivers install

Or install a specific version:

sudo ubuntu-drivers install nvidia:595

Step 4: Reboot

sudo reboot
Success! NVIDIA driver installed and loaded!

Method 2: Install via APT (Specific Version)

Step 1: Update and Search

sudo apt update
apt search nvidia-driver | grep "nvidia-driver-"

Step 2: Install Driver

sudo apt install -y nvidia-driver-595

Step 3: Reboot

sudo reboot

Method 3: Graphics Drivers PPA (Newer Versions)

Step 1: Add PPA

sudo add-apt-repository ppa:graphics-drivers/ppa

Step 2: Update and Search

sudo apt update
ubuntu-drivers devices

Step 3: Install

sudo ubuntu-drivers install

Step 4: Reboot

sudo reboot

Method 4: NVIDIA CUDA Repository

Step 1: Download and Install CUDA Keyring

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb

Step 2: Update and Install

sudo apt update
sudo apt install -y cuda-drivers

Step 3: Reboot

sudo reboot
Note: CUDA repository for Ubuntu 26.04 may return 404. Use default repo or graphics-drivers PPA on 26.04.

Method 5: Install from NVIDIA .run File (Advanced)

Step 1: Install Build Tools

sudo apt install -y build-essential libglvnd-dev pkg-config

Step 2: Download Driver

Download from: NVIDIA Driver Download

Step 3: Blacklist Nouveau

echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nvidia-nouveau.conf
echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nvidia-nouveau.conf
sudo update-initramfs -u

Step 4: Reboot to Text Mode

sudo systemctl set-default multi-user.target
sudo reboot

Step 5: Run Installer

chmod +x NVIDIA-Linux-*.run
sudo ./NVIDIA-Linux-*.run

Step 6: Restart Display Manager

sudo systemctl set-default graphical.target
sudo reboot

Server / Headless Installation

For compute-only servers (no display):

sudo apt install -y nvidia-headless-595 nvidia-utils-595

For CUDA compute:

sudo apt install -y nvidia-cuda-toolkit

Verify Installation

Check Driver Version

nvidia-smi

Shows GPU model, driver version, CUDA version, and memory usage.

Check Driver Info

cat /proc/driver/nvidia/version

Useful Commands

Monitor GPU

watch -n 1 nvidia-smi

Set Persistence Mode

sudo nvidia-smi -pm 1

List All GPUs

lspci | grep -i nvidia

NVIDIA Driver Versions

  • nvidia-driver-595 – Latest stable (Ubuntu 26.04)
  • nvidia-driver-570 – Production branch
  • nvidia-driver-550 – LTS branch
  • nvidia-driver-535 – Legacy LTS branch
  • nvidia-driver-390 – Legacy (Fermi GPUs)
  • nvidia-driver-340 – Legacy (older GPUs)

Troubleshooting

NVIDIA-SMI Not Found

sudo apt install -y nvidia-utils-595

Driver Not Loading

sudo dkms status
sudo modprobe nvidia

Secure Boot Issues

Issue: “Failed to load module” with Secure Boot

Disable Secure Boot in BIOS or enroll MOK:

sudo mokutil --disable-validation

Nouveau Conflict

lsmod | grep nouveau
echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nvidia-nouveau.conf
sudo update-initramfs -u

Black Screen After Reboot

Boot into recovery mode and purge NVIDIA:

sudo apt purge -y nvidia-* && sudo reboot

After Kernel Update

sudo dkms autoinstall
sudo apt install --reinstall nvidia-driver-595
sudo reboot

Remove NVIDIA Drivers

Purge All NVIDIA Packages

sudo apt purge -y nvidia-*
sudo apt autoremove -y
sudo update-initramfs -u
sudo reboot

Conclusion

NVIDIA drivers are now installed! You can now:

  • Use GPU acceleration for gaming and 3D
  • Run CUDA workloads and ML training
  • Monitor GPU with nvidia-smi
  • Use NVIDIA container toolkit for Docker
Pro Tip: After install, run sudo nvidia-smi -pm 1 for better GPU performance on servers.