Top Tags

Install Nvidia Drivers Ubuntu

Complete guide to installing and configuring Nvidia proprietary drivers on Ubuntu Linux

Overview

Installing Nvidia proprietary drivers on Ubuntu is essential for optimal GPU performance, CUDA support, and proper hardware acceleration. This guide covers installation methods, troubleshooting, and verification steps.

Prerequisites

Before installing Nvidia drivers, ensure your system meets these requirements:

  • Ubuntu 20.04 LTS or newer
  • Nvidia GPU (GeForce, Quadro, or Tesla series)
  • Secure Boot disabled or configured for third-party drivers
  • Active internet connection

Understanding Driver Versions

Nvidia maintains multiple driver branches:

  • Production Branch (e.g., 550.x): Most stable, recommended for production systems
  • New Feature Branch (e.g., 560.x): Latest features and hardware support
  • Legacy Branch (e.g., 470.x): For older GPUs no longer supported by current drivers

Check your GPU's compatibility on the Nvidia Driver Downloads page.

The Graphics Drivers PPA provides the latest stable Nvidia drivers for Ubuntu. This method ensures automatic updates through the package manager.

This just placeholder always check current version on Nvidia website.

bash
1sudo add-apt-repository ppa:graphics-drivers/ppa && \
2sudo apt update && \
3sudo apt install nvidia-driver-550 && \
4sudo reboot

What Each Command Does

  1. add-apt-repository: Adds the Graphics Drivers PPA repository to your system
  2. apt update: Refreshes package lists to include new PPA packages
  3. apt install: Installs the specified driver version and dependencies
  4. reboot: Required to load the new driver kernel modules

Method 2: Ubuntu Default Repository

Ubuntu's default repositories include tested Nvidia drivers, though they may be older versions.

Check Available Drivers

bash
1ubuntu-drivers devices

This command detects your GPU and lists compatible drivers with recommendations.

bash
1sudo ubuntu-drivers autoinstall

This automatically installs the recommended driver for your GPU.

Install Specific Driver Version

bash
1sudo apt install nvidia-driver-535

Replace 535 with your desired version number.

Method 3: Official Nvidia .run Installer

For advanced users requiring specific driver versions or custom installations.

Download and Install

bash
1# Download driver (replace URL with your specific driver)
2wget https://us.download.nvidia.com/XFree86/Linux-x86_64/550.54.14/NVIDIA-Linux-x86_64-550.54.14.run
3
4# Make executable
5chmod +x NVIDIA-Linux-x86_64-550.54.14.run
6
7# Stop display manager
8sudo systemctl stop gdm3 # or lightdm/sddm depending on your system
9
10# Run installer
11sudo ./NVIDIA-Linux-x86_64-550.54.14.run
12
13# Restart display manager
14sudo systemctl start gdm3

Note: This method requires manual updates and may conflict with package-managed drivers.

Verification and Testing

Check Driver Installation

bash
1nvidia-smi

Expected output shows GPU information, driver version, CUDA version, and processes using the GPU.

Verify Driver Version

bash
1cat /proc/driver/nvidia/version

Check Loaded Kernel Modules

bash
1lsmod | grep nvidia

Should display modules like nvidia, nvidia_modeset, nvidia_uvm.

Test OpenGL Rendering

bash
1glxinfo | grep "OpenGL renderer"

Should show your Nvidia GPU model, not software rendering.

Benchmark GPU Performance

bash
1# Install glmark2 if not present
2sudo apt install glmark2
3
4# Run benchmark
5glmark2

CUDA Toolkit Installation

For machine learning, scientific computing, or development requiring CUDA:

Install CUDA Toolkit

bash
1# Add CUDA repository
2wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
3sudo dpkg -i cuda-keyring_1.1-1_all.deb
4sudo apt update
5
6# Install CUDA
7sudo apt install cuda-toolkit-12-3

Verify CUDA Installation

bash
1nvcc --version

Set Environment Variables

Add to ~/.bashrc or ~/.zshrc:

bash
1export PATH=/usr/local/cuda/bin:$PATH
2export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Troubleshooting

Black Screen After Installation

Boot into recovery mode and remove the driver:

bash
1sudo apt purge nvidia-*
2sudo apt autoremove
3sudo reboot

Secure Boot Conflicts

Disable Secure Boot in BIOS/UEFI or enroll the Nvidia driver MOK (Machine Owner Key):

bash
1sudo mokutil --import /var/lib/shim-signed/mok/MOK.der

Switch Between Nvidia and Intel/AMD Graphics

For laptops with hybrid graphics:

bash
1# Install PRIME profiles
2sudo apt install nvidia-prime
3
4# Switch to Nvidia
5sudo prime-select nvidia
6
7# Switch to Intel/AMD
8sudo prime-select intel
9
10# Query current profile
11prime-select query

Driver Conflicts After Update

bash
1# Remove all Nvidia packages
2sudo apt purge nvidia-* libnvidia-*
3
4# Clean up
5sudo apt autoremove
6sudo apt autoclean
7
8# Reinstall driver
9sudo apt install nvidia-driver-550

Check for Errors in Logs

bash
1dmesg | grep -i nvidia
2journalctl -b | grep -i nvidia

Performance Tuning

Enable Persistence Mode

Keeps GPU initialized for faster response times:

bash
1sudo nvidia-smi -pm 1

Set Power Management Mode

bash
1# Maximum performance
2sudo nvidia-smi -pl 350 # Set power limit in watts
3
4# Query current power settings
5nvidia-smi -q -d POWER

Configure Cooling

bash
1# Enable manual fan control
2nvidia-settings -a "[gpu:0]/GPUFanControlState=1"
3
4# Set fan speed (0-100%)
5nvidia-settings -a "[fan:0]/GPUTargetFanSpeed=75"

Multi-GPU Configuration

List All GPUs

bash
1nvidia-smi -L

Set GPU for Specific Application

bash
1# Run application on GPU 0
2CUDA_VISIBLE_DEVICES=0 your-application
3
4# Run on GPU 1
5CUDA_VISIBLE_DEVICES=1 your-application
6
7# Use multiple GPUs
8CUDA_VISIBLE_DEVICES=0,1 your-application

Monitor All GPUs

bash
1watch -n 1 nvidia-smi

Uninstallation

Remove PPA-installed Driver

bash
1sudo apt purge nvidia-*
2sudo apt autoremove
3sudo add-apt-repository --remove ppa:graphics-drivers/ppa

Remove .run-installed Driver

bash
1sudo nvidia-uninstall

Additional Resources

Best Practices

  1. Always check compatibility before installing drivers
  2. Create a system backup before major driver updates
  3. Use package managers (apt) for easier management and updates
  4. Avoid mixing installation methods to prevent conflicts
  5. Keep drivers updated for security patches and performance improvements
  6. Test after installation to ensure everything works correctly