can't install nvidia-driver-toolkit on Ubuntu 20.04 LTS – needs uninstallable package

I’ve been trying to install nvidia-cuda-toolkit with sudo apt install nvidia-cuda-toolkit and it displays the following error:

The following packages have unmet dependencies:  nvidia-cuda-toolkit :
Depends: nvidia-cuda-dev (= 10.1.243-3) but it is not going to be
installed E: Unable to correct problems, you have held broken
packages.
Running `sudo apt install nvidia-cuda-dev` yields:

The following packages have unmet dependencies:  nvidia-cuda-dev :
Depends: libcublas10 (= 10.1.243-3) but 10.2.2.214-1 is to be
installed
                   Recommends: libvdpau-dev but it is not going to be installed
                   Recommends: libnvcuvid1 but it is not installable E: Unable to correct problems, you have held broken packages.

I tried installing it from NVIDIA’s official website, but nothing works.

UPDATE: output of sudo apt-cache show nvidia-cuda-dev:

Package: nvidia-cuda-dev Architecture: amd64 Version: 10.1.243-3
Priority: extra Section: multiverse/libdevel Source:
nvidia-cuda-toolkit Origin: Ubuntu Maintainer: Ubuntu Developers
<ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian
NVIDIA Maintainers <pkg-nvidia-devel@lists.alioth.debian.org> Bugs:
https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1100028
Depends: libcudart10.1 (= 10.1.243-3), libaccinj64-10.1 (=
10.1.243-3), libcuinj64-10.1 (= 10.1.243-3), libnvrtc10.1 (= 10.1.243-3), libnvtoolsext1 (= 10.1.243-3), libnvvm3 (= 10.1.243-3), libcublas10 (= 10.1.243-3), libcublaslt10 (= 10.1.243-3), libnvblas10
(= 10.1.243-3), libcufft10 (= 10.1.243-3), libcufftw10 (= 10.1.243-3),
libcurand10 (= 10.1.243-3), libcusolver10 (= 10.1.243-3),
libcusolvermg10 (= 10.1.243-3), libcusparse10 (= 10.1.243-3),
libnppc10 (= 10.1.243-3), libnppial10 (= 10.1.243-3), libnppicc10 (=
10.1.243-3), libnppicom10 (= 10.1.243-3), libnppidei10 (= 10.1.243-3), libnppif10 (= 10.1.243-3), libnppig10 (= 10.1.243-3), libnppim10 (=
10.1.243-3), libnppist10 (= 10.1.243-3), libnppisu10 (= 10.1.243-3), libnppitc10 (= 10.1.243-3), libnpps10 (= 10.1.243-3), libnvgraph10 (=
10.1.243-3), libnvjpeg10 (= 10.1.243-3), libcupti-dev (= 10.1.243-3), libnvidia-ml-dev (= 10.1.243-3), libthrust-dev Recommends: libcuda1
(>= 418.39) | libnvidia-tesla-cuda1 (>= 418.39) | libcuda.so.1 (>=
418.39) | libcuda-10.1-1, libgl1-mesa-dev | libgl-dev, libvdpau-dev, libnvcuvid1 Breaks: libcuda1 (<< 418.39) Filename:
pool/multiverse/n/nvidia-cuda-toolkit/nvidia-cuda-dev_10.1.243-3_amd64.deb
Size: 420308420 MD5sum: fbad3f84b31fe19a382ade63a57bc3ff SHA1:
ceb1f2e2bfdc6fafbeced70bbc707d3e9f83e6f5 SHA256:
85b188b198c53be4d24a9d706dce2252d1d4d69592691c90d4bfd0cabc04f720
Homepage: https://developer.nvidia.com/cuda-zone Description-en:
NVIDIA CUDA development files  The Compute Unified Device Architecture
(CUDA) enables NVIDIA  graphics processing units (GPUs) to be used for
massively parallel  general purpose computation.  .  This package
contains the development files: headers and libraries.
Description-md5: 23a17262479fe7daf1cae67727e949c7

I also tried following this Medium article.

Asked By: Waddles

||

I think you might have added PPAs or changed your sources.list in "/etc/apt/sources.list". If so, try first to get your sources.list to its original state (for ubuntu focal) which supposed to be something like:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

Yours might not be exactly the same but just make sure that all mirrors belong to focal.

Then list your packages sources using the command:

sudo apt-cache policy

Now if you find any PPAs related to nvidia/cuda try to remove it using the command:

sudo add-apt-repository --remove ppa:<ppa_name>/ppa

Then try to purge any nvidia or cuda related packages

sudo apt-get --purge remove "*cublas*" "cuda*" "*nvidia*"

And make sure that there are no cuda files are in /usr/local/cuda. If so remove them.
Finally, clean the cache and remove unneeded packages using:

sudo apt-get clean
sudo apt-get autoremove

Now try again the following and hopefully it will work:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nvidia-cuda-toolkit
Answered By: max

I had this issue, and was unable to upgrade from nvidia-450 to nvidia-455. Removing the old driver and reinstalling fixed it:

sudo apt-get purge 'nvidia-.*'
sudo ubuntu-drivers autoinstall
Answered By: bain

remove all packages which have depends issue in one "apt purge" command works for me.

sudo apt purge nvidia-cuda-toolkit nvidia-cuda-dev
Answered By: Shengyao Xue