How to remove CUDA completely from Linux?
If you want to reinstall CUDA or replace CUDA with another version then you are in the right place. In this blog, I will describe how to remove CUDA completely from your OS along with Nvidia drivers.
CUDA refers to Compute Unified Device Architecture. It is a parallel computing platform and provides a set of programming tools and API that allows general-purpose computing on Graphics Processing Units(GPUs). If you want to learn more about then go to the official website of Nvidia https://developer.nvidia.com/cuda-toolkit.
To remove CUDA completely from the operating system, first, we need to stop processes(eg. X Server, which manages graphical user interfaces in the Linux system) that might be using it. We can do this by stopping gdm
or lightdm
services.
sudo service gdm stop
Here, we stopped processes that might be using CUDA, now it’s time to uninstall CUDA completely from our system. During CUDA installation they recommended running CUDA uninstaller with administrative privilege because CUDA always comes with an uninstaller which is located at /usr/local/cuda-version
.
Here, I am going to uninstall cuda-10.2
from my system. This is what usr/local/cuda-10.2/bin
looks like on my system.
Now, run the CUDA uninstaller with sudo
privilege.
sudo ./cuda-uninstaller
The Uninstaller script requires various user inputs. Here, we need to select the version of CUDA to uninstall.
You already know that we are looking to uninstall cuda-10.2
so I have selected cuda-10.2
as follows. You can select options in the prompt by pressing spacebar
.
Once you have selected the version, now select Done
and press Enter
, it will take some time to completely uninstall CUDA from your system. After the uninstallation is complete, it is recommended to restart your system to ensure that all changes take effect. You can reboot your Linux system by running the following command:
sudo reboot
After restarting your system, CUDA 10.2 should be uninstalled, It can be verified by checking for any remaining CUDA-related directories of files in the /usr/local
directory. In my case, all the files and directories inside cuda-10.2/
directory have been removed.
If you also want to uninstall Nvidia-driver, then follow the following instructions.
- Search the name of packages from Nvidia that you have installed.
dpkg -l | grep -i nvidia
- Now, Purge everything related to Nvidia.
sudo apt-get remove --purge '^nvidia-.*'
But, Above command will also remove the nvidia-common
package and the nvidia-common
package has as a dependency for the ubuntu-desktop
package.
- so, install
ubuntu-desktop
package.
sudo apt-get install ubuntu-desktop
I hope that this blog is informative for you. If it works for you then please don’t forget to clap and share it. I will see you in the next blog. Thank you for reading!