Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cuda completely from ubuntu?

I have ubuntu 18.04, and accidentally installed cuda 9.1 to run Tensorflow-gpu, but it seems tensorflow-gpu requires cuda 10.0, so I want to remove cuda first by executing:

martin@nlp-server:~$ sudo apt-get remove --auto-remove nvidia-cuda-toolkit
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but 10.1.0.105-1 is to be installed
 cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but 10.1.0.105-1 is to be installed
 cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.0.168) but 10.1.0.105-1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Then I tried to run 'apt --fix-broken install', but got the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libcublas-dev
The following packages will be upgraded:
  libcublas-dev
1 upgraded, 0 newly installed, 0 to remove and 145 not upgraded.
69 not fully installed or removed.
Need to get 0 B/39.1 MB of archives.
After this operation, 3,458 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 253408 files and directories currently installed.)
Preparing to unpack .../libcublas-dev_10.2.0.168-1_amd64.deb ...

Unpacking libcublas-dev (10.2.0.168-1) over (10.1.0.105-1) .........................................................................................................................................................................................................................................................] 
dpkg: error processing archive /var/cache/apt/archives/libcublas-dev_10.2.0.168-1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libcublas_static.a', which is also in package nvidia-cuda-dev 9.1.85-3ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libcublas-dev_10.2.0.168-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

How to remove cuda completely?

like image 483
marlon Avatar asked Jun 03 '19 16:06

marlon


3 Answers

There are two things- nvidia drivers and cuda toolkit- which you may want to remove. If you have installed using apt-get use the following to remove the packages completely from the system:

To remove cuda toolkit:

sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*" 

To remove Nvidia drivers:

sudo apt-get --purge remove "*nvidia*"

If you have installed via source files (assuming the default location to be /usr/local) then remove it using:

sudo rm -rf /usr/local/cuda*

From cuda 11.4 onwards, an uninstaller script has been provided. Use it for the uninstallation instead:

# To uninstall cuda
sudo /usr/local/cuda-11.4/bin/cuda-uninstaller 
# To uninstall nvidia
sudo /usr/bin/nvidia-uninstall

If you get the problem of broken packages, it has happened since you added repo to the apt/sources.lst. Run the following to delete it:

sudo vim /etc/apt/sources.list

Go to the line containing reference to Nvidia repo and comment it by appending # in front of the line, for e.g.:

#deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /

Then run

sudo apt-get update 

This will fix the problem.

References: Nvidia uninstallation

like image 188
Manish Avatar answered Nov 19 '22 20:11

Manish


I solved this issue as follow :

sudo apt-get purge nvidia*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

This will do the job .

like image 25
smerllo Avatar answered Nov 19 '22 19:11

smerllo


Go to - /usr/local/cuda-10.2/bin

Run sudo ./cuda-uninstaller

Check all the options and then it will be uninstalled automatical

like image 12
Subham Tiwari Avatar answered Nov 19 '22 20:11

Subham Tiwari