Install Latest Nvidia Drivers: unmet dependencies

Few months ago, I updated the system from 16.04 to 18.04 with sudo do-release-upgrade. Many things broke I wasn't able to login with Nvidia Driver, etc but somehow managed to get things working.

However now when I try to update the GPU driver with sudo ubuntu-drivers autoinstall I get the following issue:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nvidia-driver-440 : Depends: libnvidia-gl-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: nvidia-dkms-440 (= 440.82-0ubuntu0~0.18.04.1)
                     Depends: nvidia-kernel-source-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: nvidia-compute-utils-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: libnvidia-decode-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: libnvidia-encode-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: xserver-xorg-video-nvidia-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: libnvidia-cfg1-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Depends: libnvidia-ifr1-440 (= 440.82-0ubuntu0~0.18.04.1) but it is not going to be installed
                     Recommends: libnvidia-compute-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
                     Recommends: libnvidia-decode-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
                     Recommends: libnvidia-encode-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
                     Recommends: libnvidia-ifr1-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
                     Recommends: libnvidia-fbc1-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
                     Recommends: libnvidia-gl-440:i386 (= 440.82-0ubuntu0~0.18.04.1)
E: Unable to correct problems, you have held broken packages.

I am not knowledgeable about the package manager and would really appreciate some help!

Note: I tried manually installing the recommended package but the package manager was removing tons of installed package which got me worried. So i cancelled the install.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apturl cuda-cudart-10-1 cuda-cudart-dev-10-1 cuda-cufft-10-1 cuda-cufft-dev-10-1 cuda-cuobjdump-10-1 cuda-curand-10-1 cuda-curand-dev-10-1 cuda-cusolver-10-1 cuda-cusolver-dev-10-1
  cuda-cusparse-10-1 cuda-cusparse-dev-10-1 cuda-driver-dev-10-1 cuda-gdb-10-1 cuda-gpu-library-advisor-10-1 cuda-libraries-10-1 cuda-libraries-dev-10-1 cuda-license-10-1 cuda-memcheck-10-1
  cuda-misc-headers-10-1 cuda-npp-10-1 cuda-npp-dev-10-1 cuda-nsight-10-1 cuda-nsight-compute-10-1 cuda-nsight-systems-10-1 cuda-nvdisasm-10-1 cuda-nvgraph-10-1 cuda-nvgraph-dev-10-1
  cuda-nvjpeg-10-1 cuda-nvjpeg-dev-10-1 cuda-nvml-dev-10-1 cuda-nvprof-10-1 cuda-nvprune-10-1 cuda-nvrtc-10-1 cuda-nvrtc-dev-10-1 cuda-nvtx-10-1 cuda-nvvp-10-1 cuda-sanitizer-api-10-1
  cuda-visual-tools-10-1 freeglut3 freeglut3-dev gstreamer1.0-gtk3 i965-va-driver ibverbs-providers libaacs0 libaio1 libavcodec-dev libavcodec57 libavutil-dev libavutil55 libbdplus0 libblas-dev
  libblas3 libbluray2 libcrystalhd3 libcublas-dev libcublas10 libdrm-dev libetonyek-0.1-1 libgl1-mesa-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libgnome-autoar-0-0
  libgoogle-perftools4 libgsm1 libibverbs1 libiscsi7 libnl-route-3-200 libnvidia-common-418 libopengl0 libopenjp2-7 libshine3 libsnappy1v5 libsoxr0 libssh-gcrypt-4 libswresample-dev libswresample2
  libtcmalloc-minimal4 libva-drm2 libva-x11-2 libva2 libwpd-0.10-10 libx11-xcb-dev libx264-152 libx265-146 libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev
  libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxdamage-dev libxshmfence-dev libxvidcore4 libxxf86vm-dev libyaml-cpp0.5v5 libzvbi-common libzvbi0 mesa-common-dev
  mesa-va-drivers mongo-tools nsight-compute-2019.4.0 nsight-systems-2019.3.7 nvidia-modprobe ocl-icd-libopencl1 va-driver-all x11proto-damage-dev x11proto-xf86vidmode-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libnvidia-common-440 libnvidia-compute-440 libnvidia-fbc1-440 nvidia-utils-440
Recommended packages:
  libnvidia-compute-440:i386 libnvidia-decode-440:i386 libnvidia-encode-440:i386 libnvidia-ifr1-440:i386 libnvidia-fbc1-440:i386 libnvidia-gl-440:i386
The following packages will be REMOVED:
  build-essential compiz-core compiz-plugins-default cuda cuda-10-1 cuda-command-line-tools-10-1 cuda-compiler-10-1 cuda-cupti-10-1 cuda-demo-suite-10-1 cuda-documentation-10-1 cuda-drivers
  cuda-nvcc-10-1 cuda-runtime-10-1 cuda-samples-10-1 cuda-toolkit-10-1 cuda-tools-10-1 eog firefox g++ g++-7 gnome-sudoku google-chrome-stable libabw-0.1-1 libavformat-dev libavformat57
  libboost-program-options1.65.1 libcdr-0.1-1 libchromaprint1 libe-book-0.1-1 libepubgen-0.1-1 libexempi3 libexiv2-14 libfreehand-0.1-1 libgexiv2-2 libgfortran4 libglibmm-2.4-1v5 libgme0
  liblapack-dev liblapack3 liblua5.2-0 libmspub-0.1-1 libnvidia-cfg1-418 libnvidia-compute-418 libnvidia-decode-418 libnvidia-encode-418 libnvidia-fbc1-418 libnvidia-gl-418 libnvidia-ifr1-418
  libopenmpt0 libpagemaker-0.0-0 libpcrecpp0v5 libproxy1-plugin-gsettings libproxy1-plugin-networkmanager libqqwing2v5 libqt4-dbus libqt4-declarative libqt4-network libqt4-script libqt4-sql
  libqt4-xmlpatterns libqt5qml5 libqt5quick5 libqt5sql5 libqt5sql5-sqlite libqtgui4 libquvi7 librados2 libraw16 librbd1 libreoffice-avmedia-backend-gstreamer libreoffice-base-core libreoffice-calc
  libreoffice-draw libreoffice-gnome libreoffice-gtk3 libreoffice-impress libreoffice-math libreoffice-ogltrans libreoffice-writer libsigc++-2.0-0v5 libsignon-extension1 libsignon-plugins-common1
  libsignon-qt5-1 libstdc++-7-dev libvisio-0.1-1 libwpg-0.3-3 libwps-0.4-4 mongodb mongodb-clients mongodb-server mongodb-server-core nautilus nautilus-share nvidia-compute-utils-418
  nvidia-dkms-418 nvidia-driver-418 nvidia-kernel-common-418 nvidia-kernel-source-418 nvidia-utils-418 printer-driver-brlaser printer-driver-splix qdbus qemu-block-extra qemu-utils
  qml-module-qtquick2 qt-at-spi qtchooser qtdeclarative5-qtquick2-plugin shotwell telnet thunderbird thunderbird-gnome-support ubuntu-desktop xserver-xorg-video-nvidia-418
The following NEW packages will be installed:
  libnvidia-cfg1-440 libnvidia-common-440 libnvidia-compute-440 libnvidia-decode-440 libnvidia-encode-440 libnvidia-fbc1-440 libnvidia-gl-440 libnvidia-ifr1-440 nvidia-compute-utils-440
  nvidia-dkms-440 nvidia-driver-440 nvidia-kernel-common-440 nvidia-kernel-source-440 nvidia-utils-440 xserver-xorg-video-nvidia-440
0 upgraded, 15 newly installed, 114 to remove and 0 not upgraded.

Solution 1:

I just dealt with the same issue on Kubuntu 20.04 when trying to install nvidia-driver-465.

derek@ds-p51-l:~$ sudo apt install nvidia-driver-465
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nvidia-driver-465 : Depends: libnvidia-gl-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: libnvidia-decode-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: libnvidia-encode-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: xserver-xorg-video-nvidia-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: libnvidia-cfg1-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: libnvidia-ifr1-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Depends: libnvidia-fbc1-465 (= 465.27-0ubuntu0.20.04.1) but it is not going to be installed
                     Recommends: libnvidia-compute-465:i386 (= 465.27-0ubuntu0.20.04.1)
                     Recommends: libnvidia-decode-465:i386 (= 465.27-0ubuntu0.20.04.1)
                     Recommends: libnvidia-encode-465:i386 (= 465.27-0ubuntu0.20.04.1)
                     Recommends: libnvidia-ifr1-465:i386 (= 465.27-0ubuntu0.20.04.1)
                     Recommends: libnvidia-fbc1-465:i386 (= 465.27-0ubuntu0.20.04.1)
                     Recommends: libnvidia-gl-465:i386 (= 465.27-0ubuntu0.20.04.1)
E: Unable to correct problems, you have held broken packages.

My active driver was 460, so I checked to see what other drivers were installed.

derek@ds-p51-l:~$ apt list -i | grep nvidia

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libnvidia-cfg1-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-common-460/focal,focal,now 460.73.01-0ubuntu0.20.04.2 all [installed,automatic]
libnvidia-compute-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-compute-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
libnvidia-decode-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-decode-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
libnvidia-encode-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-encode-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
libnvidia-extra-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-fbc1-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-fbc1-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
libnvidia-gl-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-gl-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
libnvidia-ifr1-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
libnvidia-ifr1-460/focal,now 460.73.01-0ubuntu0.20.04.2 i386 [installed,automatic]
nvidia-compute-utils-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-dkms-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-driver-440/focal-updates,focal-security,focal,now 450.119.03-0ubuntu0.20.04.1 amd64 [installed]
nvidia-driver-450/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-driver-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-kernel-common-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-kernel-source-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
nvidia-prime/focal-updates,focal-updates,now 0.8.16~0.20.04.1 all [installed,automatic]
nvidia-settings/focal-updates,focal,now 460.39-0ubuntu0.20.04.1 amd64 [installed,automatic]
nvidia-utils-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]
xserver-xorg-video-nvidia-460/focal,now 460.73.01-0ubuntu0.20.04.2 amd64 [installed,automatic]

...I decided to purge the 450 driver, which also got rid of the 440 driver.

derek@ds-p51-l:~$ sudo apt purge nvidia-*-450
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'nvidia-kernel-common-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-utils-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-dkms-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-headless-no-dkms-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-compute-utils-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-driver-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-headless-450' for glob 'nvidia-*-450'
Note, selecting 'nvidia-kernel-source-450' for glob 'nvidia-*-450'
Package 'nvidia-compute-utils-450' is not installed, so not removed
Package 'nvidia-dkms-450' is not installed, so not removed
Package 'nvidia-headless-450' is not installed, so not removed
Package 'nvidia-headless-no-dkms-450' is not installed, so not removed
Package 'nvidia-kernel-common-450' is not installed, so not removed
Package 'nvidia-kernel-source-450' is not installed, so not removed
Package 'nvidia-utils-450' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  libatomic1:i386 libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgl1:i386
  libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libllvm11:i386 libnvidia-cfg1-460 libnvidia-common-460 libnvidia-compute-460:i386 libnvidia-decode-460
  libnvidia-decode-460:i386 libnvidia-encode-460 libnvidia-encode-460:i386 libnvidia-extra-460 libnvidia-fbc1-460 libnvidia-fbc1-460:i386 libnvidia-gl-460 libnvidia-gl-460:i386 libnvidia-ifr1-460
  libnvidia-ifr1-460:i386 libpciaccess0:i386 libsensors5:i386 libstdc++6:i386 libvulkan1:i386 libwayland-client0:i386 libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386
  libxcb-glx0:i386 libxcb-present0:i386 libxcb-randr0:i386 libxcb-sync1:i386 libxcb-xfixes0:i386 libxcb1:i386 libxdamage1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxnvctrl0 libxshmfence1:i386
  libxxf86vm1:i386 mesa-vulkan-drivers:i386 nvidia-compute-utils-460 nvidia-dkms-460 nvidia-driver-460 nvidia-kernel-common-460 nvidia-kernel-source-460 nvidia-prime nvidia-settings nvidia-utils-460
  screen-resolution-extra xserver-xorg-video-nvidia-460
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  nvidia-driver-440* nvidia-driver-450*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 39.9 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 263199 files and directories currently installed.)
Removing nvidia-driver-440 (450.119.03-0ubuntu0.20.04.1) ...
Removing nvidia-driver-450 (460.73.01-0ubuntu0.20.04.2) ...

... I was then able to install the 465 driver.

derek@ds-p51-l:~$ sudo apt install nvidia-driver-465
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libnvidia-cfg1-465 libnvidia-common-465 libnvidia-compute-465 libnvidia-compute-465:i386 libnvidia-decode-465 libnvidia-decode-465:i386 libnvidia-encode-465 libnvidia-encode-465:i386 libnvidia-extra-465
  libnvidia-fbc1-465 libnvidia-fbc1-465:i386 libnvidia-gl-465 libnvidia-gl-465:i386 libnvidia-ifr1-465 libnvidia-ifr1-465:i386 nvidia-compute-utils-465 nvidia-dkms-465 nvidia-kernel-common-465
  nvidia-kernel-source-465 nvidia-utils-465 xserver-xorg-video-nvidia-465
The following packages will be REMOVED:
  libnvidia-cfg1-460 libnvidia-common-460 libnvidia-compute-460 libnvidia-compute-460:i386 libnvidia-decode-460 libnvidia-decode-460:i386 libnvidia-encode-460 libnvidia-encode-460:i386 libnvidia-extra-460
  libnvidia-fbc1-460 libnvidia-fbc1-460:i386 libnvidia-gl-460 libnvidia-gl-460:i386 libnvidia-ifr1-460 libnvidia-ifr1-460:i386 nvidia-compute-utils-460 nvidia-dkms-460 nvidia-driver-460
  nvidia-kernel-common-460 nvidia-kernel-source-460 nvidia-utils-460 xserver-xorg-video-nvidia-460
The following NEW packages will be installed:
  libnvidia-cfg1-465 libnvidia-common-465 libnvidia-compute-465 libnvidia-compute-465:i386 libnvidia-decode-465 libnvidia-decode-465:i386 libnvidia-encode-465 libnvidia-encode-465:i386 libnvidia-extra-465
  libnvidia-fbc1-465 libnvidia-fbc1-465:i386 libnvidia-gl-465 libnvidia-gl-465:i386 libnvidia-ifr1-465 libnvidia-ifr1-465:i386 nvidia-compute-utils-465 nvidia-dkms-465 nvidia-driver-465
  nvidia-kernel-common-465 nvidia-kernel-source-465 nvidia-utils-465 xserver-xorg-video-nvidia-465
0 upgraded, 22 newly installed, 22 to remove and 0 not upgraded.
Need to get 234 MB of archives.
After this operation, 102 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Solution 2:

From an Ubuntu 18.04 with current Nvidia drivers (435 or 440 depending upon kernel, no graphics-drivers ppa needed), the problem described is caused by installing a CUDA deb file with an old Nvidia 418 driver (right in the package name).
This removes (but not purges) the Nvidia 440, and a simple reinstall attempt of the 440 will fail with the above noted errors on missing dependencies.

  1. You can put the nvida-driver-435 and all the missing dependencies on one line: sudo apt-get install nvidia-driver-440 libnvidia-gl-440 etc.) and the 440 driver will get installed.
  2. When the 418 driver is removed, you will be notified about all the Cuda debs dependent upon it, and are now subject to autoremoval. This is actually a runnable state, but you really do not want a random autoremove deleting all your CUDA files.

    1. Before you do the autoremove, just copy the whole cuda directory that was installed. Use a copy that preserves links.

    2. Then, autoremove, which cleans up the package info, getting rid of all CUDA packages, and copy the CUDA directory back (or just mv it if you don't want to keep it as a backup).

You now have a CUDA installation not tied to the package system, so don't expect any updates. Maybe that's good, given how tightly tied to versions other things like DNN and Tensorflow are.


Having just gone through this on 20.04B, I thought using the .run file might avoid these problems, and allow skipping the Nvidia driver mess.

There are other CUDA packages which do not contain the Nvidia drivers. Look for the entire list of .deb files, and maybe a top level one (which pulls in all the others) will work. There are such debs without "nvidia" in their names, so I'd think that should work.

I can understand why Nvidia did this, that's what they built and tested, and really don't want to spend any effort supporting untested configurations, but CUDA is just an app, which may be installed by a user without touching any system files.

I think the older CUDA versions just had files in their top level deb, so a simple extract, and change PATH and LD_LIBRARY_PATH works.