Failed installation of package breaks apt-get
Solution 1
I fix this issue only with:
sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
Solution 2
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.
Solution 3
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
Solution 4
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}}
fi
Related videos on Youtube
StrugglingProgrammer
The road to success is paved with compilation errors.
Updated on September 18, 2022Comments
-
StrugglingProgrammer over 1 year
I just installed Ubuntu 18.04 for the first time. Excited to play with some GPU codes, I installed CUDA via the
deb (local)
for17.10
option, as described on the Nvidia CUDA page. I know17.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 samenvidia-396
error encountered above.It appears my attempted installation of
cuda
has putapt-get
into a state such that it will no longer install or remove any packages, due to an unmet dependencies error. Worded more simply, installingcuda
has brokenapt-get
completely.How can I get my package manager working again?
-
StrugglingProgrammer almost 6 yearsTried
sudo apt-get purge nvidia*
without any luck -
MatsK almost 6 yearsDid you run
sudo apt --fix-broken install
? In your question, you omittedsudo
? -
StrugglingProgrammer almost 6 yearsYes. It results in the same error mentioned earlier.
-
MatsK almost 6 yearsWhen 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/…
-
StrugglingProgrammer almost 6 years@MatsK - Note that this question is asking how to get
apt
working again (without reinstalling the OS), rather than getting CUDA toolkit installed. -
StrugglingProgrammer almost 6 yearsI attempted to install CUDA exactly as I've described in the original question.
-
-
escapecharacter over 5 yearsI 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 over 5 yearsResolution: I was trying to install on 18.04; I gave up and have downloaded 16.04 and will try with that one.
-
temple almost 5 yearsthis fixed my problem.
-
Lucas Azevedo about 4 yearsit also fixed my problem, but an explanation on why it does would be nice. Thank you very much for the solution, anyways!
-
malanb5 about 4 yearsThanks for this
-
wbadry over 3 yearsA magician indeed. Thanks
-
clifgray over 3 yearsThis also worked for me but could we get some details on what exactly this is doing?
-
Lawhatre almost 3 yearsIt didn't worked for me. Got
Errors were encountered while processing: nvidia-dkms-418 nvidia-driver-418 cuda-drivers cuda-runtime-10-1 cuda-demo-suite-10-1 cuda-10-1 cuda E: Sub-process /usr/bin/dpkg returned an error code (1)