Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vredchenko/42381e9cff3f1e162cb47cfd6479c459 to your computer and use it in GitHub Desktop.
Save vredchenko/42381e9cff3f1e162cb47cfd6479c459 to your computer and use it in GitHub Desktop.
NVIDIA GPU Linux driver switching guide

NVIDIA GPU Linux Driver Switching Guide

Overview

This guide covers switching between NVIDIA's proprietary driver and the open-source Nouveau driver on Ubuntu/Debian-based systems.

Driver Types

Proprietary NVIDIA Driver

  • Pros: Best performance, CUDA support, full feature set, power management
  • Cons: Closed-source, potential compatibility issues with kernel updates
  • Use cases: Gaming, ML/AI workloads, professional graphics work

Nouveau Driver

  • Pros: Open-source, built into kernel, better Wayland support, no licensing concerns
  • Cons: Lower performance, limited power management, no CUDA support
  • Use cases: Basic desktop use, troubleshooting, avoiding proprietary software

Checking Current Status

Check GPU Hardware

lspci | grep -i vga
lspci | grep -i nvidia

Check Currently Loaded Driver

lsmod | grep -E "(nvidia|nouveau)"

Check NVIDIA Driver Status

nvidia-smi
# Or check version
cat /proc/driver/nvidia/version

Check Display Driver in Use

glxinfo | grep "OpenGL renderer"
# Or
inxi -G

Installing and Switching to Nouveau

Method 1: Ubuntu Driver Manager (GUI)

  1. Open "Software & Updates"
  2. Go to "Additional Drivers" tab
  3. Select "Using X.Org X server -- Nouveau" driver
  4. Click "Apply Changes"
  5. Reboot system

Method 2: Command Line

# Remove NVIDIA proprietary driver
sudo apt purge nvidia-* libnvidia-*

# Update package database
sudo apt update

# Install Nouveau (usually already included)
sudo apt install xserver-xorg-video-nouveau

# Regenerate initramfs
sudo update-initramfs -u

# Reboot
sudo reboot

Method 3: Blacklist NVIDIA Driver

# Create blacklist file
sudo nano /etc/modprobe.d/blacklist-nvidia.conf

# Add these lines:
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
blacklist nvidia-uvm
alias nvidia off
alias nvidia-drm off
alias nvidia-modeset off
alias nvidia-uvm off

# Update initramfs and reboot
sudo update-initramfs -u
sudo reboot

Installing NVIDIA Proprietary Driver

Method 1: Ubuntu Driver Manager (GUI)

  1. Open "Software & Updates"
  2. Go to "Additional Drivers" tab
  3. Select recommended NVIDIA driver (usually highest version)
  4. Click "Apply Changes"
  5. Reboot system

Method 2: Auto-install Recommended Driver

# Install recommended driver automatically
sudo ubuntu-drivers autoinstall

# Or list available drivers first
ubuntu-drivers devices

# Install specific version
sudo apt install nvidia-driver-535  # Replace with desired version

Method 3: Official NVIDIA Repository

# Add NVIDIA package repository
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt update

# Install driver
sudo apt install nvidia-driver-535  # Latest stable version

Method 4: Manual Installation (Advanced)

# Download driver from NVIDIA website
# Make runfile executable and run
chmod +x NVIDIA-Linux-x86_64-*.run
sudo ./NVIDIA-Linux-x86_64-*.run

Switching Between Drivers

Quick Switch Script

Create a script to easily switch:

#!/bin/bash
# save as switch-gpu-driver.sh

case "$1" in
    nvidia)
        echo "Switching to NVIDIA proprietary driver..."
        sudo rm -f /etc/modprobe.d/blacklist-nvidia.conf
        sudo ubuntu-drivers autoinstall
        ;;
    nouveau)
        echo "Switching to Nouveau driver..."
        sudo apt purge nvidia-* libnvidia-*
        sudo tee /etc/modprobe.d/blacklist-nvidia.conf << EOF
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
blacklist nvidia-uvm
EOF
        ;;
    *)
        echo "Usage: $0 {nvidia|nouveau}"
        exit 1
        ;;
esac

sudo update-initramfs -u
echo "Reboot required to complete driver switch"

Using nvidia-prime (For Laptops with Hybrid Graphics)

# Install nvidia-prime
sudo apt install nvidia-prime

# Switch to NVIDIA
sudo prime-select nvidia

# Switch to Intel/AMD integrated graphics
sudo prime-select intel

# Check current selection
prime-select query

Compatibility Check

Nouveau Compatibility

Nouveau supports most NVIDIA cards but with limitations:

  • Full support: GeForce 8 and newer (Tesla, Fermi, Kepler, Maxwell, Pascal)
  • Limited support: Turing, Ampere (RTX 20/30 series) - basic display only
  • No support: Ada Lovelace (RTX 40 series) - very limited

Check Nouveau Support for Your GPU

# Check GPU codename
lspci -v | grep -A 12 VGA

# Visit nouveau.freedesktop.org/FeatureMatrix.html for compatibility

Troubleshooting

Common Issues and Solutions

Black Screen After Driver Switch

# Boot into recovery mode or TTY (Ctrl+Alt+F2)
# Reinstall display manager
sudo apt install --reinstall gdm3  # or lightdm/sddm

# Regenerate X11 config
sudo nvidia-xconfig  # for NVIDIA
# or remove xorg.conf for Nouveau
sudo rm /etc/X11/xorg.conf

Performance Issues with Nouveau

# Enable GPU reclocking (experimental)
sudo nano /etc/default/grub
# Add to GRUB_CMDLINE_LINUX_DEFAULT:
nouveau.pstate=1

sudo update-grub
sudo reboot

NVIDIA Driver Won't Load

# Check secure boot status
mokutil --sb-state

# If secure boot is enabled, sign the driver or disable secure boot
# Disable secure boot in BIOS/UEFI settings

Wayland Issues with NVIDIA

# Enable Wayland support for NVIDIA (driver 495+)
sudo nano /etc/gdm3/custom.conf
# Uncomment: WaylandEnable=true

# Add kernel parameters
sudo nano /etc/default/grub
# Add: nvidia-drm.modeset=1

Performance Comparison

Benchmarking Commands

# OpenGL performance
glxgears -info

# Detailed GPU info
glxinfo | grep -E "(OpenGL vendor|OpenGL renderer|OpenGL version)"

# Gaming benchmarks
sudo apt install mesa-utils
# Run specific game benchmarks or synthetic tests

System Configuration Files

Important Locations

  • /etc/modprobe.d/ - Driver blacklist files
  • /etc/X11/xorg.conf - X11 configuration
  • /usr/share/X11/xorg.conf.d/ - X11 config snippets
  • /var/log/Xorg.0.log - X11 log file

Backup Important Configs

# Before making changes
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
sudo cp -r /etc/modprobe.d/ /etc/modprobe.d.backup/

Final Notes

  • Always reboot after driver changes
  • Keep a live USB handy for recovery
  • Test thoroughly after switching
  • Consider your use case when choosing drivers
  • Nouveau is improving but still lags behind proprietary drivers for performance

For the latest information, check:

  • Ubuntu documentation
  • NVIDIA developer documentation
  • Nouveau project website
  • Your specific GPU's compatibility matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment