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:
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?

  • Tried sudo apt-get purge nvidia* without any luck Jun 8, 2018 at 14:52
  • Did you run sudo apt --fix-broken install? In your question, you omitted sudo?
    – MatsK
    Jun 8, 2018 at 14:55
  • Yes. It results in the same error mentioned earlier. Jun 8, 2018 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, 2018 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. Jun 8, 2018 at 15:10

4 Answers 4


I fix this issue only with:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
  • this fixed my problem.
    – temple
    May 14, 2019 at 19:58
  • 5
    it also fixed my problem, but an explanation on why it does would be nice. Thank you very much for the solution, anyways! Apr 12, 2020 at 13:17
  • Thanks for this
    – malanb5
    Apr 19, 2020 at 19:01
  • A magician indeed. Thanks
    – wbadry
    Oct 18, 2020 at 14:19
  • 1
    This also worked for me but could we get some details on what exactly this is doing?
    – clifgray
    Nov 24, 2020 at 15:35

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.


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
  • 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? Aug 9, 2018 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. Aug 9, 2018 at 20:30

I excuted

sudo add-apt-repository ppa:graphics-drivers
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'

(b) Install CUDA 10.1 packages, including the CuDNN library

sudo apt update
sudo apt install cuda-10-1
sudo apt install libcudnn7

Check this link I didnt remove any driver just installed above stuff and updated .profile

nano ~/.profile
# set PATH for cuda 10.1 installation
if [ -d "/usr/local/cuda-10.1/bin/" ]; then
    export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

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.