In this tutorial, we explain how to uninstall the NVIDIA CUDA Toolkit and NVCC Compiler and driver on Linux Ubuntu. The motivation for uninstalling the NVIDIA CUDA Toolkit comes from the fact that if you are experimenting with machine learning algorithms and large language models, you would often need to install and uninstall the NVIDIA CUDA Toolkit. For example, sometimes it is necessary to downgrade the NVIDIA CUDA Toolkit to a previous version. To do that, the best strategy is to perform a clean uninstall of the NVIDIA CUDA Toolkit.
The YouTube tutorial explaining how to uninstall the NVIDIA CUDA Toolkit is given below.
To uninstall NVIDIA CUDA Toolkit and NVCC driver, open a Linux ubuntu terminal and type this
sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" \
"*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
sudo apt-get autoremove --purge -V
After that, edit the .bashrc file in the home folder and erase the line that adds the CUDA installation folder to the path.
cd ~
sudo nano .bashrc
The line that should be erased is
export PATH=/usr/local/cuda-12.6/bin${PATH:+:${PATH}}