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.
Method 1: Graphics Drivers PPA (Recommended)
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.
1sudo add-apt-repository ppa:graphics-drivers/ppa && \2sudo apt update && \3sudo apt install nvidia-driver-550 && \4sudo rebootWhat Each Command Does
- add-apt-repository: Adds the Graphics Drivers PPA repository to your system
- apt update: Refreshes package lists to include new PPA packages
- apt install: Installs the specified driver version and dependencies
- 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
1ubuntu-drivers devicesThis command detects your GPU and lists compatible drivers with recommendations.
Install Recommended Driver
1sudo ubuntu-drivers autoinstallThis automatically installs the recommended driver for your GPU.
Install Specific Driver Version
1sudo apt install nvidia-driver-535Replace 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
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.run3
4# Make executable5chmod +x NVIDIA-Linux-x86_64-550.54.14.run6
7# Stop display manager8sudo systemctl stop gdm3 # or lightdm/sddm depending on your system9
10# Run installer11sudo ./NVIDIA-Linux-x86_64-550.54.14.run12
13# Restart display manager14sudo systemctl start gdm3Note: This method requires manual updates and may conflict with package-managed drivers.
Verification and Testing
Check Driver Installation
1nvidia-smiExpected output shows GPU information, driver version, CUDA version, and processes using the GPU.
Verify Driver Version
1cat /proc/driver/nvidia/versionCheck Loaded Kernel Modules
1lsmod | grep nvidiaShould display modules like nvidia, nvidia_modeset, nvidia_uvm.
Test OpenGL Rendering
1glxinfo | grep "OpenGL renderer"Should show your Nvidia GPU model, not software rendering.
Benchmark GPU Performance
1# Install glmark2 if not present2sudo apt install glmark23
4# Run benchmark5glmark2CUDA Toolkit Installation
For machine learning, scientific computing, or development requiring CUDA:
Install CUDA Toolkit
1# Add CUDA repository2wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb3sudo dpkg -i cuda-keyring_1.1-1_all.deb4sudo apt update5
6# Install CUDA7sudo apt install cuda-toolkit-12-3Verify CUDA Installation
1nvcc --versionSet Environment Variables
Add to ~/.bashrc or ~/.zshrc:
1export PATH=/usr/local/cuda/bin:$PATH2export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATHTroubleshooting
Black Screen After Installation
Boot into recovery mode and remove the driver:
1sudo apt purge nvidia-*2sudo apt autoremove3sudo rebootSecure Boot Conflicts
Disable Secure Boot in BIOS/UEFI or enroll the Nvidia driver MOK (Machine Owner Key):
1sudo mokutil --import /var/lib/shim-signed/mok/MOK.derSwitch Between Nvidia and Intel/AMD Graphics
For laptops with hybrid graphics:
1# Install PRIME profiles2sudo apt install nvidia-prime3
4# Switch to Nvidia5sudo prime-select nvidia6
7# Switch to Intel/AMD8sudo prime-select intel9
10# Query current profile11prime-select queryDriver Conflicts After Update
1# Remove all Nvidia packages2sudo apt purge nvidia-* libnvidia-*3
4# Clean up5sudo apt autoremove6sudo apt autoclean7
8# Reinstall driver9sudo apt install nvidia-driver-550Check for Errors in Logs
1dmesg | grep -i nvidia2journalctl -b | grep -i nvidiaPerformance Tuning
Enable Persistence Mode
Keeps GPU initialized for faster response times:
1sudo nvidia-smi -pm 1Set Power Management Mode
1# Maximum performance2sudo nvidia-smi -pl 350 # Set power limit in watts3
4# Query current power settings5nvidia-smi -q -d POWERConfigure Cooling
1# Enable manual fan control2nvidia-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
1nvidia-smi -LSet GPU for Specific Application
1# Run application on GPU 02CUDA_VISIBLE_DEVICES=0 your-application3
4# Run on GPU 15CUDA_VISIBLE_DEVICES=1 your-application6
7# Use multiple GPUs8CUDA_VISIBLE_DEVICES=0,1 your-applicationMonitor All GPUs
1watch -n 1 nvidia-smiUninstallation
Remove PPA-installed Driver
1sudo apt purge nvidia-*2sudo apt autoremove3sudo add-apt-repository --remove ppa:graphics-drivers/ppaRemove .run-installed Driver
1sudo nvidia-uninstallAdditional Resources
- Nvidia Documentation: Official Linux Driver Installation Guide
- Ubuntu Wiki: Nvidia Graphics Drivers
- CUDA Documentation: CUDA Toolkit Documentation
Best Practices
- Always check compatibility before installing drivers
- Create a system backup before major driver updates
- Use package managers (apt) for easier management and updates
- Avoid mixing installation methods to prevent conflicts
- Keep drivers updated for security patches and performance improvements
- Test after installation to ensure everything works correctly