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
- Administrative (sudo) access to the Ubuntu system.
- Internet access to download the necessary packages.
Steps
Remove Existing NVIDIA Drivers
First, we need to remove any existing NVIDIA drivers from the system.
sudo apt-get remove --purge '^nvidia-.*'
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
- 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* - 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 - Update the Package List
Update the package list to include the latest drivers from the added PPA.
sudo apt update - 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 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:
- Update and Upgrade the System (Optional)
Update and upgrade all packages to ensure the system is up-to-date.
sudo apt update
sudo apt upgrade
- 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 - Reboot the System
Finally, reboot the system to apply all changes.
sudo reboot - 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 ...