Removing Nvidia CUDA Toolkit and installing new one
I installed the CUDA 5.5 package on Ubuntu 14.04 (which is not supported for this version of Ubuntu version) , and I didn't do it well.
I want to remove what I've installed earlier and install a new CUDA 6.5 toolkit,
After typing this in the terminal: dpkg -l | grep -i nvidia
,
I get the following output:
ii bbswitch-dkms 0.8-1~trustyppa1 all Interface for toggling the power on NVIDIA Optimus video cards
ii bumblebee 3.2.1-90~trustyppa1 amd64 NVIDIA Optimus support
ii bumblebee-nvidia 3.2.1-90~trustyppa1 amd64 NVIDIA Optimus support using the proprietary NVIDIA driver
ii libcublas5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA BLAS runtime library
ii libcuda1-331 331.38-0ubuntu7.1 amd64 NVIDIA CUDA runtime library
ii libcudart5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA runtime library
ii libcufft5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA FFT runtime library
ii libcufftw5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA FFTW runtime library
ii libcuinj64-5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA INJ runtime library (64-bit)
ii libcurand5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA Random Numbers Generation runtime library
ii libcusparse5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA Sparse Matrix runtime library
ii libnppc5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA Performance Primitives core runtime library
ii libnppi5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA Performance Primitives for image processing runtime library
ii libnpps5.5:amd64 5.5.22-3ubuntu1 amd64 NVIDIA Performance Primitives for signal processing runtime library
ii libnvtoolsext1:amd64 5.5.22-3ubuntu1 amd64 NVIDIA Tools Extension
ii libnvvm2:amd64 5.5.22-3ubuntu1 amd64 NVIDIA CUDA Compiler NVVM runtime library
ii nvidia-331 331.38-0ubuntu7.1 amd64 NVIDIA binary driver - version 331.38
ii nvidia-cuda-dev 5.5.22-3ubuntu1 amd64 NVIDIA CUDA development files
ii nvidia-cuda-doc 5.5.22-3ubuntu1 all NVIDIA CUDA and OpenCL documentation
ii nvidia-cuda-gdb 5.5.22-3ubuntu1 amd64 NVIDIA CUDA GDB
ii nvidia-cuda-toolkit 5.5.22-3ubuntu1 amd64 NVIDIA CUDA toolkit
ii nvidia-libopencl1-331 331.38-0ubuntu7.1 amd64 NVIDIA OpenCL Driver and ICD Loader library
ii nvidia-nsight 5.5.22-3ubuntu1 amd64 NVIDIA Nsight Eclipse Edition
ii nvidia-opencl-dev:amd64 5.5.22-3ubuntu1 amd64 NVIDIA OpenCL development files
ii nvidia-opencl-icd-331 331.38-0ubuntu7.1 amd64 NVIDIA OpenCL ICD
ii nvidia-profiler 5.5.22-3ubuntu1 amd64 NVIDIA Profiler for CUDA and OpenCL
ii nvidia-settings 331.20-0ubuntu8 amd64 Tool for configuring the NVIDIA graphics driver
ii nvidia-visual-profiler 5.5.22-3ubuntu1 amd64 NVIDIA Visual Profiler
ii primus
I'd like to remove only what is needed to install the newest CUDA toolkit. Packages, like bumblebee, I want to remain as they are.
Which packages should I remove and which should not be removed to get this done?
This method will give a complete removal of Cuda:
Simple
remove the CUDA files in /usr/local/cuda-5.0
Advanced
Uninstall just nvidia-cuda-toolkit
sudo apt-get remove nvidia-cuda-toolkit
Uninstall nvidia-cuda-toolkit and it's dependencies
sudo apt-get remove --auto-remove nvidia-cuda-toolkit
Purging config/data
sudo apt-get purge nvidia-cuda-toolkit
or
sudo apt-get purge --auto-remove nvidia-cuda-toolkit
Additionally, delete the /opt/cuda
and ~/NVIDIA_GPU_Computing_SDK
folders if they are present. and remove the export PATH=$PATH:/opt/cuda/bin
and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib:/opt/cuda/lib64
lines of the ~/.bash_profile
file
Nvidia has prepared a file for removing cuda (I guess this method is standard one).First of all change directory to cuda path,which in default ,it is /usr/local/cuda-x.y/bin
which x.y
is your cuda version, you can change the directory with using the below command:(I have cuda 9.0=x.y
)
cd /usr/local/cuda-9.0/bin
In this directory there is a file which it's name is uninstall_cuda_9.0.pl
(please pay attention that my cuda version is 9.0
) , so you just need to run uninstall_cuda_9.0.pl
to remove cuda completely from your system!!
chmod +x uninstall_cuda_9.0.pl
sudo ./uninstall_cuda_9.0.pl
After entering your password the cuda files are going to erase . ( it may take a few minutes to complete)
NOTE: How to know which cuda has installed in your ubuntu?
You can check it by the nvcc
command, in the last line of the nvcc result you can see that my cuda version is 9.0
nvcc --version
result of this command will be like as below:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
Note that the above method works if you set $PATH variable correctly, So if your nvcc
command not works then please use the below command in terminal to find cuda version
ls /usr/local/ | grep cuda
UPDATE
I have installed cuda 10.2 on my system and it seems that there isn't uninstall_cuda_x.x.pl
file, but nvidia replaced this file by cuda-uninstaller
file in the same directory.
Make sure the method you use to install cuda toolkit. This answer is for whom use deb
files to install cuda. I have no idea if this works for .run
files.
sudo apt-get autoremove --purge cuda
This can clear the cuda toolkit clearly. You can check that the folder /usr/local/cuda
gone. And this command is the best choice to remove apt installed app.
But when you reinstall another version of cuda, you must use:
sudo apt-get install cuda-x.x
the version number must be included. I tried to install another version of cuda after the remove of the previous version, I find that sudo apt-get install cuda
will still install the previous one.
For CUDA 10.1 or newer, try:
sudo /usr/local/cuda/bin/cuda-uninstaller
For CUDA 10.0, try:
sudo /usr/local/cuda/bin/uninstall_cuda_10.0.pl