How to Install NVIDIA Drivers on Ubuntu (2026 Guide)

✅ Tested on Ubuntu 24.04 LTS, Ubuntu 22.04 LTS, Linux Mint 22 — Last updated: June 2026
Installing NVIDIA drivers on Ubuntu is essential if you want hardware-accelerated graphics, CUDA for AI workloads, or just a properly configured desktop GPU. This guide covers the two main methods — the automatic driver tool and manual installation — plus how to install CUDA, verify everything works, and fix the most common problems.
Table of Contents
- Before You Start
- Method 1: Ubuntu Driver Tool (Easiest)
- Method 2: NVIDIA Official Repository
- Method 3: Manual .run Installer
- Install CUDA Toolkit
- Verify Installation
- Use with AI Tools (Ollama, PyTorch)
- Troubleshooting
- Uninstall NVIDIA Drivers
- FAQ
Before You Start
Check Your GPU
lspci | grep -i nvidia
# Example output:
# 01:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)Check Currently Installed Drivers
nvidia-smi 2>/dev/null || echo "No NVIDIA driver detected"
# Check what kernel modules are loaded:
lsmod | grep nvidiaUpdate Your System First
sudo apt update && sudo apt upgrade -y
sudo rebootAlways update before installing drivers. Running an outdated kernel with new drivers causes compatibility problems.
Understand Secure Boot
If your system has Secure Boot enabled (common on modern laptops), NVIDIA drivers need to be signed to load. Ubuntu handles this automatically with MOK (Machine Owner Key) enrollment — you'll be prompted to create a password during installation and need to enroll the key on the next boot.
Method 1: Ubuntu Driver Tool (Easiest)
This is the recommended method for most users. Ubuntu's ubuntu-drivers tool detects your GPU and installs the appropriate driver automatically.
Step 1: See Available Drivers
ubuntu-drivers devices
# Example output:
# == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
# modalias : pci:v000010DEd00002204sv00...
# vendor : NVIDIA Corporation
# model : GA102 [GeForce RTX 3090]
# driver : nvidia-driver-550 - distro non-free recommended
# driver : nvidia-driver-535 - distro non-free
# driver : nvidia-driver-470 - distro non-freeStep 2: Install the Recommended Driver
# Install the recommended driver automatically:
sudo ubuntu-drivers install
# Or install a specific version:
sudo ubuntu-drivers install nvidia:550Step 3: Reboot
sudo rebootIf Secure Boot is enabled, the reboot will take you to the MOK management screen. Choose Enroll MOK, enter the password you set during installation, and select Continue. The system will boot normally after that.
Graphical Method (for Desktop Systems)
On Ubuntu Desktop, open Software & Updates → Additional Drivers. Select the recommended NVIDIA driver and click Apply Changes. Reboot when done.
Method 2: NVIDIA Official Repository (Latest Drivers)
Use this method when you need the very latest driver version, often required for new GPU models or the latest CUDA features.
# Install prerequisites:
sudo apt install software-properties-common -y
# Add NVIDIA PPA:
sudo add-apt-repository ppa:graphics-drivers/ppa -y
sudo apt update
# See available versions:
apt-cache search nvidia-driver | grep "^nvidia-driver" | sort
# Install latest (check the highest number available):
sudo apt install nvidia-driver-560 -y
# Reboot:
sudo rebootThe PPA always has newer versions than the Ubuntu default repositories. This is the best option if the ubuntu-drivers method installed an older version than what your GPU supports.
Method 3: Manual .run Installer
This is the most complex method and rarely necessary. Only use it if the other methods fail or you need a very specific driver version for production use.
# 1. Remove existing NVIDIA packages:
sudo apt purge nvidia* libnvidia*
sudo apt autoremove
# 2. Install build dependencies:
sudo apt install build-essential dkms linux-headers-$(uname -r)
# 3. Disable nouveau (open source NVIDIA driver):
sudo bash -c "echo 'blacklist nouveau
options nouveau modeset=0' > /etc/modprobe.d/blacklist-nouveau.conf"
sudo update-initramfs -u
# 4. Reboot to text mode (Ctrl+Alt+F2 if needed to exit GUI):
sudo systemctl set-default multi-user.target
sudo reboot
# 5. Download the .run file from nvidia.com/drivers
# Then run:
chmod +x NVIDIA-Linux-x86_64-560.xx.run
sudo ./NVIDIA-Linux-x86_64-560.xx.run
# 6. After installation, restore graphical boot:
sudo systemctl set-default graphical.target
sudo reboot⚠️ The .run installer bypasses package management. Updates don't happen automatically and it can break after kernel updates. Only use it if you know what you're doing.
Install CUDA Toolkit
CUDA is NVIDIA's parallel computing platform. Required for running AI workloads (PyTorch, TensorFlow, Ollama with GPU), video encoding with NVENC, and scientific computing.
Check CUDA Compatibility
First, check the maximum CUDA version your driver supports:
nvidia-smi
# Look for "CUDA Version: XX.X" in the top-right corner.
# This is the MAXIMUM CUDA version the driver supports.
# You can install any CUDA toolkit version up to that number.| NVIDIA Driver | Max CUDA Version |
|---|---|
| 545+ | CUDA 12.3+ |
| 520–544 | CUDA 12.0–12.2 |
| 470–519 | CUDA 11.8 |
| 450–469 | CUDA 11.0 |
Install CUDA via Package Manager (Recommended)
# Add NVIDIA CUDA repository:
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
sudo apt update
# Install full CUDA toolkit (large download ~4GB):
sudo apt install cuda-toolkit-12-4
# Or install a lighter version with just the runtime:
sudo apt install cuda-runtime-12-4Set Up CUDA Environment Variables
# Add to ~/.bashrc:
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
# Verify:
nvcc --version
# nvcc: NVIDIA (R) Cuda compiler driver
# Copyright (c) 2005-2024 NVIDIA Corporation
# Built on ...
# Cuda compilation tools, release 12.4, V12.4.99Verify the Installation
nvidia-smi
nvidia-smi
# Expected output:
# +-----------------------------------------------------------------------------------------+
# | NVIDIA-SMI 550.107.02 Driver Version: 550.107.02 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. |
# |=========================================+========================+======================|
# | 0 NVIDIA GeForce RTX 4090 Off | 00000000:01:00.0 Off | N/A |
# | 0% 32C P8 9W / 450W | 1MiB / 24564MiB | 0% Default |
# +-----------------------------------------------------------------------------------------+Watch GPU Usage in Real Time
watch -n 1 nvidia-smiTest CUDA with PyTorch
pip install torch --index-url https://download.pytorch.org/whl/cu124
python3 -c "
import torch
print('PyTorch version:', torch.__version__)
print('CUDA available:', torch.cuda.is_available())
print('CUDA version:', torch.version.cuda)
print('GPU:', torch.cuda.get_device_name(0))
print('VRAM:', round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 1), 'GB')
"Use GPU with AI Tools
Ollama
If you have the NVIDIA driver installed, Ollama automatically uses your GPU with no extra configuration:
curl -fsSL https://ollama.com/install.sh | sh
ollama run llama3.2
# Verify GPU is being used:
nvidia-smi # You should see Ollama using GPU memoryGPU VRAM Requirements for LLMs
| Model Size | VRAM Needed (4-bit) | VRAM Needed (full) | Example Models |
|---|---|---|---|
| 3B | 2 GB | 6 GB | Phi-3 Mini, Llama 3.2 3B |
| 7B | 4 GB | 14 GB | Mistral 7B, Llama 3.1 8B |
| 13B | 8 GB | 26 GB | Llama 2 13B, CodeLlama 13B |
| 34B | 20 GB | 68 GB | CodeLlama 34B |
| 70B | 40 GB | 140 GB | Llama 3.1 70B, Qwen 72B |
Models that don't fit in VRAM fall back to CPU or split across GPU+CPU (partial offload). GPU inference is typically 10-30x faster than CPU for LLMs.
Troubleshooting
Black screen after installing NVIDIA drivers
This is the most common problem, especially if the open-source nouveau driver conflicts with NVIDIA's driver.
# Boot into recovery mode or press Ctrl+Alt+F2 for TTY
# Remove NVIDIA and reinstall:
sudo apt purge nvidia* libnvidia*
sudo apt autoremove
sudo reboot
# Check if nouveau is causing conflicts:
lsmod | grep nouveau
# Blacklist nouveau permanently:
sudo bash -c "cat >> /etc/modprobe.d/blacklist.conf << 'EOF'
blacklist nouveau
options nouveau modeset=0
EOF"
sudo update-initramfs -u
sudo reboot
# Then reinstall drivers:
sudo ubuntu-drivers installnvidia-smi: NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver
# Check if the kernel module is loaded:
lsmod | grep nvidia
# If not loaded, try loading manually:
sudo modprobe nvidia
# Check dmesg for errors:
sudo dmesg | grep -i nvidia | tail -30
# Common fix — reinstall with dkms:
sudo apt install --reinstall nvidia-dkms-550
sudo dkms status
sudo rebootDriver works but no CUDA
# Check CUDA installation:
ls /usr/local/cuda/
nvcc --version 2>/dev/null || echo "CUDA not in PATH"
# Check PATH:
echo $PATH | grep cuda
# If not there, add to ~/.bashrc:
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
source ~/.bashrcDriver breaks after kernel update
This happens when using the manual .run installer. With DKMS-based packages (from apt), the driver automatically recompiles for new kernels. If you're experiencing this:
# Reinstall driver to trigger DKMS recompile:
sudo apt install --reinstall nvidia-driver-550
# Or manually trigger DKMS build:
sudo dkms autoinstall
# Check DKMS status:
sudo dkms statusTwo GPUs — integrated Intel + NVIDIA (laptops)
# Check prime status:
prime-select query
# Switch to NVIDIA (uses more battery):
sudo prime-select nvidia
# Switch to Intel (saves battery):
sudo prime-select intel
# On-demand mode (NVIDIA only used when needed — modern laptops):
sudo prime-select on-demand
# Reboot after switchingUninstall NVIDIA Drivers
# Remove all NVIDIA packages:
sudo apt purge nvidia* libnvidia* cuda* libcuda*
sudo apt autoremove
# Remove NVIDIA PPA if added:
sudo add-apt-repository --remove ppa:graphics-drivers/ppa
sudo apt update
sudo rebootFrequently Asked Questions
Which NVIDIA driver version should I install?
Install the version marked as "recommended" by ubuntu-drivers devices. In 2026, that's typically the 550 or 560 series for most GPUs. Avoid the "server" or "headless" variants unless you're on a server without a display. Don't install drivers older than what your GPU supports.
Do I need CUDA for gaming?
No. CUDA is for computation (AI, rendering, scientific computing). For gaming, you only need the NVIDIA driver. Install it, reboot, and your games will work through Steam or Proton.
Can I run NVIDIA GPU on Wayland?
Yes. NVIDIA driver 545+ has proper Wayland support. Ubuntu 24.04 uses Wayland by default. If you're experiencing issues with older drivers, switching to X11 in the login screen (click the gear icon) resolves most problems.
What's the difference between the open and proprietary NVIDIA driver?
NVIDIA released an open-source kernel module in 2022. It's separate from the nouveau driver. For modern GPUs (Turing/RTX 2000 series and newer), the open kernel module is recommended and often installed by default. The proprietary closed-source module is still available and required for older GPUs. The open module has equivalent performance and better systemd/Wayland integration.
My GPU is too old — what NVIDIA driver should I use?
NVIDIA groups GPUs into driver series based on architecture. If your GPU is Kepler (GTX 600/700 series), the latest driver that supports it is 470.xx. For Fermi (GTX 400/500) and older, you're limited to 390.xx, which is end-of-life. These older cards still work for display output but won't run modern CUDA workloads like AI inference.
With your GPU drivers and CUDA set up, you're ready to run GPU-accelerated AI locally. Check out our guides on installing Ollama to run LLMs like Llama 3, or Open WebUI for a ChatGPT-style interface to your local models.
