11

The following is the message I get when trying to install anything on Ubuntu, right now.

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

I tried apt --fix-broken install, I tried purge, I tried sudo apt install -f, and also sudo apt-get remove --purge '^nvidia-.*' and I am not able to get anything done. It all fails.

I tired rebooting in recovery mode to try and uninstall the drivers.

This is my output for 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:
  libcublas-dev
The following NEW packages will be installed:
  libcublas-dev
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
8 not fully installed or removed.
Need to get 0 B/39.9 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 735451 files and directories currently installed.)
Preparing to unpack .../libcublas-dev_10.1.0.105-1_amd64.deb ...
Unpacking libcublas-dev (10.1.0.105-1) ...
dpkg: error processing archive /var/cache/apt/archives/libcublas-dev_10.1.0.105-1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/cublas_v2.h', 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.1.0.105-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Can someone please help me? I've been spending hours trying to fix this. I tried installing cuda 10.1 along with an already present installation of cuda 9.1. This turned out to be a mistake. My older cuda installation works fine, but dpkg completely broke, and it is not working anymore.

Without uninstalling the previous version of cuda, I directly tried installing the 10.1 version (by mistake). I tried installing by following the link given here: https://developer.nvidia.com/cuda-downloads. I selected: Linux -> x86_64 -> Ubuntu -> 18.04 -> deb(network) And I followed the instructions over there.

I am not able to install anything, because of this.

Sreram
  • 659
  • 1
    What release of Ubuntu are you using? I did a package check for one chosen at random (https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=libcublas), and it requires the 19.04 version (Ubuntu 19.04 is off-topic until it's release later in the month) – guiverc Apr 08 '19 at 09:49
  • I'm using Ubuntu 18.04 – Sreram Apr 08 '19 at 10:11
  • 1
    @guiverc I think those packages come from the nvidia repo that the user downloaded from https://developer.nvidia.com/cuda-downloads when they chose to download "deb(network)" which is basically a ppa installer but it's just a repo and not a ppa. – mchid Apr 08 '19 at 10:11
  • Sorry, the "deb(local)" is the downloaded deb installer. To remove the "deb(network)" installed version, see the answer by @jithu83 below. – mchid Mar 06 '20 at 01:37

3 Answers3

16

Okay, to back out of this, run the following commands:

sudo rm /etc/apt/sources.list.d/cuda.list
sudo apt-get clean
sudo apt-get update
sudo apt install -f

This will uninstall the nvidia repo you downloaded and installed and hopefully the system will fix itself now. If not, we can fix it manually fairly easily by following the error messages.

You may need to do some more purging and we may have to use dpkg to do that manually so please post any more errors. Thanks!

mchid
  • 43,546
  • 8
  • 97
  • 150
  • Thank you very much!!! I was now able to completely remove Nvidia! I used purge and uninstalled everything. – Sreram Apr 08 '19 at 10:14
  • @Sreram Awesome, that was easier than I thought. – mchid Apr 08 '19 at 10:15
  • 1
    @Sreram Please let me know if you have trouble re-installing nvidia and cuda9.1. – mchid Apr 08 '19 at 10:17
  • I am using a DELL laptop which has an 1050ti. I have already encountered numerous problems with this particular laptop and graphical drivers. This answer surely deserves credit since it allowed me to fix update related issues. Thanks a lot. – Meto Jul 08 '20 at 10:51
9

In my case, removing packages causing collision solved the problem.

dpkg -P nvidia-cuda-toolkit nvidia-cuda-dev
apt --fix-broken install
2

I had to comment out the following line in the file /etc/apt/sources.list

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

and then run

sudo apt --fix-broken install

That resolved the broken package manager problem created by trying to install CUDA Toolkit 10.2 Download on Ubuntu 18.04 by following Nvidia instructions

jithu83
  • 121
  • You can delete the line by using the -r or --remove option with: sudo add-apt-repository -r "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" – mchid Mar 06 '20 at 01:13