5

I downloaded and installed an application that uses CUDA 10. When I run it, it says:

./main: error while loading shared libraries: libcublas.so.10.0: cannot open shared object file: No such file or directory

The documentation said, that it required CUDA 10 and cuDNN. So, I downloaded and installed both. (... Well, actually I installed CUDA 10.1). But none of that helped. I wasn't sure which one to install, so I installed both the dev and the runtime.

And because still that didn't help, I installed the nvidia-cuda-toolkit. I think that's when things really went wrong. The inevitable happened, I broke it.

I wanted to install one more package: i.e. "cuda-libraries", but it gives an unmet dependency error, refering back to the nvidia toolkit that I installed earlier.

user@dxxx:~/x$ sudo apt install cuda-libraries-10-0
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-10-0 : Depends: cuda-nvrtc-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-nvgraph-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-nvjpeg-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cusolver-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cublas-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cufft-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-curand-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cusparse-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-npp-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-cudart-10-0 (>= 10.0.130) but it is not going to be installed
                       Depends: cuda-license-10-0 (>= 10.0.130) but it is not going to be installed
 nvidia-cuda-toolkit : Depends: nvidia-cuda-dev (= 9.1.85-3ubuntu1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Right now, I can't go back nor forth. When I try to uninstall it gives errors.

user@xxx:~/x$ sudo apt autoremove
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:
 nvidia-cuda-toolkit : Depends: nvidia-cuda-dev (= 9.1.85-3ubuntu1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Also, the broken-fix switch doesn't help. It tries to install something, then goes in error again.

user@xxx:~/x$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libnvidia-common-390
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  nvidia-cuda-dev
Recommended packages:
  libnvcuvid1
The following NEW packages will be installed:
  nvidia-cuda-dev
0 upgraded, 1 newly installed, 0 to remove and 142 not upgraded.
54 not fully installed or removed.
Need to get 0 B/263 MB of archives.
After this operation, 734 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 205855 files and directories currently installed.)
Preparing to unpack .../nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb ...
Unpacking nvidia-cuda-dev (9.1.85-3ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/cublas.h', which is also in package libcublas-dev 10.2.0.168-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I save my system? e.g. uninstalling all of it.

bvdb
  • 153

3 Answers3

6

I had basically the same problem, but the accepted answer did not work in my case (Ubuntu 18.04). I had installed cuda-10.1, but (as in the original question) cuda-9.1 was still present. This post was helpful.

dpkg -l | grep -e cuda-.*9-1 | awk '{print $2}' | xargs -n1 sudo dpkg --purge --force-all
sudo apt-get remove nvidia-cuda-toolkit

These two lines should remove 9.1 (it should vanish from /usr/local). Now to clean up:

sudo apt autoremove
sudo apt update && sudo apt full-upgrade
2

For a new beginning. sudo mv /usr/include/cublas.h /usr/include/cublas.h.bak

dpkg: error processing archive /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb (--unpack): trying to overwrite '/usr/include/cublas.h', which is also in package libcublas-dev 10.2.0.168-1

2 packages include the same file and dpkg do not override it without any --force option.

sudo dpkg --configure nvidia-cuda-dev and ` sudo dpkg --configure nvidia-cuda-toolkit`

Then try to remove the package that violate apt. sudo dpkg -P cuda-libraries-10-0 libnvidia-common-390

Next step

sudo dpkg --configure -a && sudo apt -f install

some packages need to upgrade. But only if you receive no error message before.

sudo apt update && sudo apt full-upgrade
nobody
  • 5,437
  • 1
    after the mv everything worked perfectly. Did an autoremove of the toolkit and installed the missing libraries. Everything looks fine now. And the application is even running. mission accomplished – bvdb Jun 19 '19 at 21:20
1

Neither the accepted answer nor the answer of user3658307 solved the issue for me (Ubuntu 18.04.5 LTS; /usr/include/cublas.h conflicting with libcublas-dev 10.2.2.89-1 instead of 10.2.0.168-1 as in the question). Instead, the following solution based on this answer worked for me:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb

Executing this lead to a lot of dpkg: warning: messages and even this output:

[...]

dpkg: error processing package nvidia-cuda-dev (--install): dependency problems - leaving unconfigured

[...]

However, running the following afterwards fixed the broken dependencies on my machine:

sudo apt -f install
ToJo
  • 111