The general issue
I'm regularly having issues with previously installed Nvidia package dependencies. About once every two months when I try to upgrade my system or install something new (non-nvidia related), suddenly there's some conflict that prevents me from going forward. On such occasions apt suggests to run apt --fix-broken install which sometimes helps but other times doesn't, at least on its own. So far I've been able to solve such occurrences by doing dpkg --remove --force-depends on some specific conflicting package and running apt --fix-broken install then, which solves the issue, but I would like know why this keeps happening and how to prevent it happening in the future if possible.
A specific example
The latest example of what I've described above is this:
❯ sudo apt upgrade
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:
libnvidia-gl-535 : Breaks: libnvidia-gl-535:i386 (!= 535.161.07-0ubuntu1) but 535.171.04-0ubuntu0.20.04.1 is installed
libnvidia-gl-535:i386 : Breaks: libnvidia-gl-535 (!= 535.171.04-0ubuntu0.20.04.1) but 535.161.07-0ubuntu1 is installed
nvidia-dkms-535 : Depends: nvidia-kernel-common-535 (>= 535.171.04) but 535.161.07-0ubuntu1 is installed
nvidia-driver-535 : Depends: libnvidia-gl-535 (= 535.171.04-0ubuntu0.20.04.1) but 535.161.07-0ubuntu1 is installed
Depends: nvidia-kernel-common-535 (>= 535.171.04) but 535.161.07-0ubuntu1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Here it looks like libnvidia-gl-535 and libnvidia-gl-535:i386 conflicting versions, which I find weird because afaik they should be coming from the same place. Here's what aptitude why got to say about these packages:
❯ aptitude why libnvidia-gl-535
i cuda-drivers Depends cuda-drivers-535 (= 535.104.12-1)
i A cuda-drivers-535 Depends libnvidia-gl-535 (>= 535.104.12)
❯ aptitude why libnvidia-gl-535:i386
i cuda-drivers Depends cuda-drivers-535 (= 535.104.12-1)
i A cuda-drivers-535 Depends nvidia-driver-535 (>= 535.104.12)
BBA nvidia-driver-535 Recommends libnvidia-gl-535:i386 (= 535.171.04-0ubuntu0.20.04.1)
BBA libnvidia-gl-535:i386 Provides libnvidia-gl-535:i386
And to verify that the versions are indeed different:
❯ apt list --installed | grep libnvidia-gl
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libnvidia-gl-535/unknown,now 535.161.07-0ubuntu1 amd64 [installed,upgradable to: 535.161.08-0ubuntu1]
libnvidia-gl-535/focal-updates,focal-security,now 535.171.04-0ubuntu0.20.04.1 i386 [installed,automatic]
So at this point I have several questions:
- How did it end up like this, what triggered it?
- Why is there
unknownafterlibnvidia-gl-535/? - Seeing that
libnvidia-gl-535andlibnvidia-gl-535:i386are ultimately are pulled in bycuda-driverswhy aren't their versions always the same (and not in conflict)?
This time I managed to solve the issue with a simple
sudo apt --fix-broken install
but on other similar occasions I haven't been so fortunate.
A bit more background
The previous instance of a similar issue was a very similar looking conflict regarding libnvidia-compute-535 and nvidia-firmware-535-535.161.07 which I managed to fix by running:
sudo dpkg --remove --force-depends libnvidia-compute-535
sudo dpkg --remove --force-depends nvidia-firmware-535-535.161.07
sudo apt --fix-broken install
And there have been earlier similar-looking instances as well regarding some other Nvidia packages (of which I don't recall much about unfortunately).
A thing that might influence stuff here is that I also have
deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /
deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
repos added for CUDA and Nvidia docker stuff.