18

I've been working on installing CUDA for TensorFlow usage.

I realized that cuda-9.0 has been just released today, and I accidentally downloaded and dpkged it, and installed it on my machine.

I realized that cuda-9.0 is not yet compatible with TensorFlow so I had to uninstall it with:

sudo apt autoremove cuda

Which did remove everything, but now whenever I try to install cuda-8.0, after downloading and dpkging, it prompts me to install cuda-9.0 instead.

Now I know I can work around this with:

sudo apt-get install cuda-8-0

But I also need to install the patch, which can't be done this way.

I've been trying many methods to resolve this issue:

  1. sudo apt-get remove cuda-9-0-blablal
  2. Removing the apt-key of cuda-9 with:
    • apt-key del [KEY]

But none of these really worked.

Can someone help me out?

UPDATE

Right after posting this, I figured out the answer, which turned out to be simple.

I'm leaving it for others:

I was able to solve it simply, by removing cuda-9 stuff from /etc/apt/sources.list.d/cuda-9-0-local.list

UPDATE 2 And now I have another problem which is after

sudo dpkg -i cuda-8-0-blabla

none of it appears on sources.list.d anymore.

Jay Shin
  • 343
  • 1
    Actually, I was able to solve it simply, by removing cuda-9 stuff from /etc/apt/sources.list.d/cuda-9-0-local.list – Jay Shin Sep 27 '17 at 07:58

7 Answers7

18

I got the exact same issue and managed to fix it. First observation was that the cuda-8 related entries in sources.list.d/ were commented out, but removing these and doing the dpkg --install of the cuda-8 repo did not repopulate the sources.list.d/ entries. What worked was to purge the 'dpkg' install (/var/cuda*) manually and doing the 'dpkg --install' again.

step by step:

  • dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 sudo dpkg --purge
  • dpkg --install cuda-repo-ubuntu*-8.0-local*.deb
  • sudo apt-get update
  • sudo apt-get install cuda
Beef
  • 296
6

There's actually a script in /usr/local/cuda-9.x/bin/ which performs the uninstall process for you.

3

https://devtalk.nvidia.com/default/topic/1024342/cuda-setup-and-installation/unable-to-uninstall-cuda-9-0-completely-and-install-8-0-instead/

It works for me. It might be helpful for you too.

NickVot
  • 31
2

I had to add "--force-all" to the purge command:

dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 sudo dpkg --purge --force-all
Yoel
  • 21
2

The above command

sudo apt-get install cuda-8-0

might have worked but does not any more! You must change it into the following line - it is an almost undetectable difference:

sudo apt-get install cuda-8.0

The ending is not "-0" but ".0"!

2

The official way is to run a uninstaller script:

Taken from nVidia documentation:

4.6. Uninstallation

To uninstall the CUDA Toolkit, run the uninstallation script provided in the bin directory of the toolkit. By default, go to /usr/local/cuda-9.1/bin and run

$ sudo ./uninstall_cuda_9.1.pl
Hrvoje
  • 131
  • I don't have any such file (cuda-10.2). Also I think this is only the official way when you installed cude using a .run file, not when you use a .deb package manager. – Carlo Wood Mar 14 '20 at 21:42
1

As answered by @Beef earlier:

  1. dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 sudo dpkg --purge
  2. dpkg --install cuda-repo-ubuntu*-8.0-local*.deb
  3. sudo apt-get update
  4. sudo apt-get install cuda

It doesn't work now. I realized step 1 doesn't remove cuda completely. I still had to do:

  • sudo apt-get remove cuda-* in order to remove my cuda-9-1 version and others.

Additionally when you are using deb(network) version or the deb(local), on doing:

sudo apt-get install cuda

It lists down cuda-9-1 the latest drivers. Refer to here.

The step 4 in instruction shown by @beef should be instead:

sudo apt-get install cuda-8-0