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 ...
    • Enable AI Eye contact and Noise cancelling using NVIDIA Broadcast

      What is NVIDIA Broadcast? NVIDIA Broadcast allows you to enhance your voice and video for calls and live streaming with the power of AI. System Requirements You need to have an RTX Powered NVIDIA GPU and Windows 10/11 for NVIDIA Broadcast to work. ...
    • Enable Root Login in GUI Lock Screen in Ubuntu.

      How to Enable Root Login in Ubuntu in Login Screen. Do you have Trouble to Login as root user in Ubuntu like this? Steps to Enable Root Login Login as other user as you Define in Installation time. Open the Terminal, shortcut to open Terminal ...
    • Setup noVNC on Ubuntu 20.04/Gnome 3.36

      VNC (Virtual Network Computing) enables you to control your Linux installation from another computer on the same network, by viewing and interacting with the desktop from the other computer. To learn more about VNC, click here noVNC allows you to ...
    • Configuration to Enable ssh(Remote) Login in Ubuntu.

      How to Enable ssh (Remote) Login in Ubuntu. Have a Trouble to Access ssh Login in Ubuntu. Steps to Configure ssh configuration file. Go to your system/VM and Open Terminal (use ctl+atl+t) and Follow Commands. Open sshd_config file in any editor like ...