How to Remove and Reinstall NVIDIA Drivers on Ubuntu

How to Remove and Reinstall NVIDIA Drivers on Ubuntu


This article provides step by step guide to completely remove existing NVIDIA drivers and reinstall specific version of the NVIDIA driver on the Ubuntu system

Prerequisites

  1. Administrative (sudo) access to the Ubuntu system.
  2. Internet access to download the necessary packages.

Steps

  1. Remove Existing NVIDIA Drivers
    First, we need to remove any existing NVIDIA drivers from the system.
    sudo apt-get remove --purge '^nvidia-.*'
  2. Clean Up Unused Packages
    Remove any packages that are no longer needed.
    sudo apt autoremove
    Clean up the local repository of retrieved package files.
    sudo apt autoclean
  3. Remove NVIDIA-related Files
    Next, we need to remove any remaining NVIDIA-related files from various directories.
    sudo rm -rf /usr/local/cuda*
    sudo rm -rf /usr/local/nvidia*
    sudo rm -rf /usr/lib/nvidia*
    sudo rm -rf /usr/include/nvidia*
    sudo rm -rf /etc/systemd/system/nvidia*
  4. Add the Graphics Drivers PPA
    To ensure we have access to the latest drivers, add the graphics drivers PPA (Personal Package Archive).
    sudo add-apt-repository ppa:graphics-drivers/ppa
  5. Update the Package List
    Update the package list to include the latest drivers from the added PPA.
    sudo apt update
  6. Install the Specific NVIDIA Driver Version
    Install the specific version of the NVIDIA driver. In this example, we are installing version 535.161.08-0ubuntu2.22.04.1.
    sudo apt install nvidia-driver-535-server=535.161.08-0ubuntu2.22.04.1
  7. Check the APT Sources 
    Verify the /etc/apt/sources.list file  to ensure all repositories are correctly listed .If not edit your sudo nano /etc/apt/sources.list to ensure the updates and security repositories are enabled. It should contain lines similar to these:
    deb http://archive.ubuntu.com/ubuntu jammy main restricted
    deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
    deb http://archive.ubuntu.com/ubuntu jammy universe
    deb http://archive.ubuntu.com/ubuntu jammy-updates universe
    deb http://archive.ubuntu.com/ubuntu jammy multiverse
    deb http://archive.ubuntu.com/ubuntu jammy-updates multiverse
    deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
    deb http://security.ubuntu.com/ubuntu jammy-security main restricted
    deb http://security.ubuntu.com/ubuntu jammy-security universe
    deb http://security.ubuntu.com/ubuntu jammy-security multiverse
  8. Update and Upgrade the System (Optional)
  9. Update and upgrade all packages to ensure the system is up-to-date.
    sudo apt update
    sudo apt upgrade
  10. Install the NVIDIA Driver Again (Optional)
    If needed, reinstall the NVIDIA driver to ensure it's correctly installed.
    sudo apt install nvidia-driver-535-server=535.161.08-0ubuntu2.22.04.1
  11. Reboot the System
    Finally, reboot the system to apply all changes.
    sudo reboot
  12. Verify the Installation
    After rebooting, verify that the NVIDIA driver is loaded and nvidia-smi works.

Conclusion

Following these steps will completely remove any existing NVIDIA drivers and reinstall the specified version on your Ubuntu system. This can help resolve issues related to driver conflicts or corrupt installations.
If you encounter any issues or need further assistance, please consult the official NVIDIA documentation or reach out to your system administrator.

    • Related Articles

    • Installing NVIDIA Drivers on Ubuntu

      Ubuntu doesn't come with NVIDIA drivers installed by default as they are proprietary and closed-source. This means that you'll have issues like poor performance, displays not working, artifacts etc... while using the FOSS nouveau drivers. Graphical ...
    • How to Set NVIDIA GPU Power Limit on Ubuntu using nvidia-smi

      Managing the power consumption of your NVIDIA GPU on Ubuntu is a practical way to optimize energy efficiency, especially for workloads that do not require full GPU performance. This guide explains how to check and set power limits for your NVIDIA GPU ...
    • Nvidia Quadro Sync Installation

      The NVIDIA Quadro Sync card is designed as an add-on card for NVIDIA RTX/Quadro series GPUs. The NVIDIA Quadro Sync II card fits into a free PCI Express slot within the system. Hardware Installation Steps to Install the NVIDIA Quadro Sync Card Power ...
    • UBUNTU 23.04 Desktop Installation

      UBUNTU 23.04 Desktop Installation Before you begin, ensure that you have a storage plan and raid configuration (Servers) on your systems. It is recommended that you install Ubuntu on a separate disc to protect your data in the scenario where the OS ...
    • Nvidia-smi Tool Alert - Troubleshooting Guide

      Purpose This document provides a standardized approach for handling and troubleshooting the Nvidia-smi Tool alert, including L1 and L2 actions, escalation guidelines, and resolution criteria. Alert Name Nvidia-smi Tool Alert Description This alert is ...