10

I just installed Ubuntu 18.04 for the first time. Excited to play with some GPU codes, I installed CUDA via the deb (local) for 17.10 option, as described on the Nvidia CUDA page. I know 17.10 != 18.04, but I had read of people having success with this.

I followed the installation instructions provided by Nvidia:

sudo dpkg -i cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

The last command resulted in an error when installing nvidia-396:

Get:1 file:/var/cuda-repo-9-2-local  nvidia-396 396.26-0ubuntu1 [80.0 MB]
(Reading database ... 167630 files and directories currently installed.)
Preparing to unpack .../nvidia-396_396.26-0ubuntu1_amd64.deb ...
Unpacking nvidia-396 (396.26-0ubuntu1) ...
dpkg: error processing archive /var/cuda-repo-9-2-local/./nvidia-396_396.26-0ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0', which is also in package libglx-mesa0:amd64 18.0.0~rc5-1ubuntu1
Errors were encountered while processing:
 /var/cuda-repo-9-2-local/./nvidia-396_396.26-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Maybe I bit off more than I could chew, so I decided to move onto less challenging things. I proceeded to install some basic packages, such as git, but upon doing so, I got this error:

> sudo apt-get install git
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-drivers : Depends: nvidia-396 (>= 396.26) but it is not going to be installed
 git : Depends: liberror-perl but it is not going to be installed
       Depends: git-man (> 1:2.17.1) but it is not going to be installed
       Depends: git-man (< 1:2.17.1-.) but it is not going to be installed
 libcuda1-396 : Depends: nvidia-396 (>= 396.26) but it is not going to be installed
 nvidia-396-dev : Depends: nvidia-396 (>= 396.26) but it is not going to be installed
 nvidia-opencl-icd-396 : Depends: nvidia-396 (>= 396.26) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Trying the suggested sudo apt --fix-broken install command results in the same nvidia-396 error encountered above.

It appears my attempted installation of cuda has put apt-get into a state such that it will no longer install or remove any packages, due to an unmet dependencies error. Worded more simply, installing cuda has broken apt-get completely.

How can I get my package manager working again?

| improve this question | | | | |
  • Tried sudo apt-get purge nvidia* without any luck – StrugglingProgrammer Jun 8 '18 at 14:52
  • Did you run sudo apt --fix-broken install? In your question, you omitted sudo? – MatsK Jun 8 '18 at 14:55
  • Yes. It results in the same error mentioned earlier. – StrugglingProgrammer Jun 8 '18 at 14:57
  • When you write "I know 17.10 != 18.04, but I had read of people having success with this." is they following the NVIDIA way or do they install it like this ? askubuntu.com/questions/1030886/… – MatsK Jun 8 '18 at 15:08
  • @MatsK - Note that this question is asking how to get apt working again (without reinstalling the OS), rather than getting CUDA toolkit installed. – StrugglingProgrammer Jun 8 '18 at 15:10
33

I fix this issue only with:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
| improve this answer | | | | |
  • this fixed my problem. – temple May 14 '19 at 19:58
  • it also fixed my problem, but an explanation on why it does would be nice. Thank you very much for the solution, anyways! – Lucas Azevedo Apr 12 at 13:17
  • Thanks for this – malanb5 Apr 19 at 19:01
2

I resolved this by removing everything installed in a single apt-get remove command:

sudo apt-get remove --purge nvidia* cuda-drivers libcuda1-396 cuda-runtime-9-2 cuda-9.2 cuda-demo-suite-9-2  cuda
| improve this answer | | | | |
  • I did the remove --purge approach too to fix my broken install, but when I reinstall I get the same errors as you did the first time. Did it "just work" for you? – escapecharacter Aug 9 '18 at 18:16
  • Resolution: I was trying to install on 18.04; I gave up and have downloaded 16.04 and will try with that one. – escapecharacter Aug 9 '18 at 20:30
1

Similar to the command of StrugglingProgrammer, I had to make sure I would uninstall all cuda packages (the cuda-demo*, e.g.)

You can check which those might be with:

dpkg -l | grep -i cuda
dpkg -l | grep -i nvidia

So maybe try either

sudo apt-get remove --purge cuda-* libcuda* nvidia* 

(for the whole batch) or select more specifically like:

sudo apt-get remove --purge cuda-drivers libcuda* cuda-runtime* cuda-8-0 cuda-demo*

For me specifially (after trying a failed install of cuda-8-0 and libcudnn6) it was:

sudo apt-get remove --purge nvidia* cuda-drivers libcuda* cuda-runtime* cuda-8-0 cuda-demo*

Hope that may be of help.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.