8

On Ubuntu 18.04, I am having some problems with my installation of CUDA, so I would like to uninstall CUDA and start from scratch.

So, I tried the following:

sudo apt remove cuda

But this then printed out the following:

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.1.243) but it is not going to be installed
 cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed
 cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I am very confused by this. It seems to be telling me that cuda-libraries-dev-10-1, cuda-samples-10-1, and cuda-visual-tools-10-1 all depend on libcublas-dev, with at least version 10.2.1.243. And then it is saying that this version of libcublas-dev is not going to be installed. But I am trying to unistall CUDA, not install it. Therefore, why should my system care that some of the packages that come with CUDA have unmet dependencies, when I am trying to remove these packages anyway?

I can understand that if I was trying to install cuda-libraries-dev-10-1, cuda-samples-10-1, or cuda-visual-tools-10-1, then this message would make sense. But if I am trying to remove these, who cares whether they have unmet dependencies?


Update

As suggested, I also ran:

apt --fix-broken install

This then printed out:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  g++-6 libaccinj64-9.1 libcublas9.1 libcudart9.1 libcufft9.1 libcufftw9.1 libcuinj64-9.1 libcurand9.1 libcusolver9.1 libcusparse9.1 libnppc9.1 libnppial9.1 libnppicc9.1
  libnppicom9.1 libnppidei9.1 libnppif9.1 libnppig9.1 libnppim9.1 libnppist9.1 libnppisu9.1 libnppitc9.1 libnpps9.1 libnvblas9.1 libnvgraph9.1 libnvrtc9.1 libnvtoolsext1 libnvvm3
  libstdc++-6-dev libthrust-dev libvdpau-dev nvidia-cuda-dev nvidia-cuda-doc nvidia-cuda-gdb nvidia-opencl-dev nvidia-profiler nvidia-visual-profiler ocl-icd-opencl-dev
  opencl-c-headers
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libcublas-dev
The following NEW packages will be installed
  libcublas-dev
0 to upgrade, 1 to newly install, 0 to remove and 62 not to upgrade.
83 not fully installed or removed.
Need to get 0 B/38.9 MB of archives.
After this operation, 109 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Get:1 file:/var/cuda-repo-10-1-local-10.1.243-418.87.00  libcublas-dev 10.2.1.243-1 [38.9 MB]
(Reading database ... 211122 files and directories currently installed.)
Preparing to unpack .../libcublas-dev_10.2.1.243-1_amd64.deb ...
Unpacking libcublas-dev (10.2.1.243-1) ...
dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-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/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Update

As suggested in the comments, I then tried running:

sudo apt full-upgrade

This printed out the following:

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.1.243) but it is not installed
 cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not installed
 cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

This is exactly the same print out as when I ran sudo apt remove cuda.


Update

As suggested in the comments, I ran grep -r deb /etc/apt/sources.list /etc/apt/sources.list.d. This gave the following output:

/etc/apt/sources.list:#deb cdrom:[Ubuntu 18.04.3 LTS _Bionic Beaver_ - Release amd64 (20190805)]/ bionic main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic universe
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic universe
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
/etc/apt/sources.list:# deb http://archive.canonical.com/ubuntu bionic partner
/etc/apt/sources.list:# deb-src http://archive.canonical.com/ubuntu bionic partner
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security main restricted
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security universe
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security multiverse
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
/etc/apt/sources.list.d/cuda.list:deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /
/etc/apt/sources.list.d/cuda-10-0-local-10.0.130-410.48.list:deb file:///var/cuda-repo-10-0-local-10.0.130-410.48 /
/etc/apt/sources.list.d/cuda-10-1-local-10.1.243-418.87.00.list:deb file:///var/cuda-repo-10-1-local-10.1.243-418.87.00 /
Karnivaurus
  • 1,024
  • 3
  • 15
  • 34
  • apt is telling you twice to run apt --fix-broken install. Have you tried that? – Murphy Sep 03 '19 at 15:44
  • @Murphy Yes I have run this, and have updated my question with the result – Karnivaurus Sep 03 '19 at 15:48
  • Your system seems to be having issues beyond just CUDA. Run sudo apt update and then sudo apt full-upgrade. Post the entire output here. – DK Bose Sep 03 '19 at 15:58
  • @DKBose I have just tried this, and updated my question with the result – Karnivaurus Sep 03 '19 at 16:53
  • Did you first run sudo apt update? Where is that output? – DK Bose Sep 03 '19 at 16:56
  • Yes, I did. The output printed a few lines, the final line being: 62 packages can be upgraded. Run 'apt list --upgradable' to see them.. So I ran apt list --upgradeable, and of the 62 packages listed, the only one containing cuda is: cuda-repo-ubuntu1804/unknown 10.1.243-1 amd64 [upgradable from: 10.0.130-1] – Karnivaurus Sep 03 '19 at 17:00

4 Answers4

6

I had the same problem. This saved me (replace with your package version):

sudo dpkg -i --force-overwrite /var/cache/apt/archives/libcublas-dev_10.2.1.243-1_amd64.deb

And then:

sudo apt --fix-broken install
Eliah Kagan
  • 117,780
Mortezaaa
  • 161
3

dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-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)

2 Packages ,that have the same file

sudo mv usr/lib/x86_64-linux-gnu/libcublas_static.a usr/lib/x86_64-linux-gnu/libcublas_static.a.bak

Then

sudo dpkg --configure -a 

If this work, try to purge cuda again

nobody
  • 5,437
  • I ran sudo mv /usr/lib/x86_64-linux-gnu/libcublas_static.a /usr/lib/x86_64-linux-gnu/libcublas_static.a.bak, and then sudo dpkg --configure -a, which printed out a number of errors. For example: dpkg: dependency problems prevent configuration of cuda-visual-tools-10-1: cuda-visual-tools-10-1 depends on libcublas-dev (>= 10.2.1.243); however: Package libcublas-dev is not installed. and dpkg: error processing package cuda-visual-tools-10-1 (--configure): dependency problems - leaving unconfigured. – Karnivaurus Sep 03 '19 at 17:06
  • grep -r deb /etc/apt/sources.list /etc/apt/sources.list.d please edit your question for output. – nobody Sep 03 '19 at 17:23
  • Thank you -- I have done this and added the output to my question. – Karnivaurus Sep 03 '19 at 18:19
1

Unpacking libcublas-dev (10.2.1.243-1) ... dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-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

Let's explain this error a bit: You have two packages that are incompatible because each tries to provide the same file. The two packages are libcublas-dev (from CUDA) and nvidia-cuda-dev (from Ubuntu).

The file that they both try to provide is /usr/lib/x86_64-linux-gnu/libcublas_static.a

You have several options.

  1. You can give up on CUDA, uninstall the CUDA packages, and delete the CUDA repositories.

  2. You can uninstall the NVIDIA package. DON'T delete the Ubuntu repositories.

  3. You can use dpkg's --force-overwrite flag to make the two otherwise-incompatible packages work together. Then you needn't uninstall or delete anything.

    sudo apt install --force-overwrite libcublas-dev
    

    Using --force should be done with care. It might cause future problems with upgrades, removals, or other package actions. Be sure to document in your own notes that you needed to use --force-overwrite to install CUDA and NVIDIA packages together.

user535733
  • 62,253
  • Thanks for your reply. I understand this a little better now, and I'd like to go with option 2 and just install with the CUDA package (i.e. the .deb file I downloaded from the CUDA website). However, I'm not sure how to uninstall the Ubuntu package. If I just run 'sudo apt remove cuda', then this was the cause of the original post I created. In apt remove cuda, how do I know which package cuda is actually referring to? How can I make it refer to the Ubuntu package, rather than the CUDA package? – Karnivaurus Sep 03 '19 at 19:16
  • "cuda" doesn't refer to anything. You must use the complete, correctly-spelled package names. Happily, the complete, correctly-spelled package names are already in the output you provided. For example, the Ubuntu-provided package is nvidia-cuda-dev. Note that if you installed that package for some other reason (like, say, NVIDIA compatibility), you may wish to investigate the consequences of removal so you're not surprised if your displays go blank. – user535733 Sep 03 '19 at 19:22
  • Thanks. I tried sudo apt remove nvidia-cuda-dev, but this output: The following packages have unmet dependencies. cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). It's the same if I run sudo apt remove libcublas-dev. – Karnivaurus Sep 03 '19 at 19:33
  • Of course it's the same: Apt remembers what you tell it to do, and keeps trying every time you start it. Try using dpkg instead for the removal, then apt for the installs. – user535733 Sep 03 '19 at 19:48
0

In the CUDA documentation for Removing CUDA toolkit 10.1 and driver it is documented that you need to use the following command:

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

When you use sudo apt-get --purge remove cuda you are using the meta packages and the system will start trying to resolve the packages. it worked with me as I was installing it on Ubuntu 20.04

aibrahim
  • 267