Nvidia-driver-470 does not install on Ubuntu 20.04 LTS

Hello,

I’m attempting to install the NVIDIA driver version 470 on my Ubuntu 20.04 LTS. I have tried various things I found online, which seemed vaguely relevant, but unfortunately to no avail. My latest attempt, which in theory should just work, is to attempt a clean install:

$ sudo apt purge nvidia* libnvidia*
$ sudo apt install nvidia-driver-470

However, this appears to be running into configuration problems during the install:

Setting up nvidia-kernel-source-470 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-prime (0.8.16~0.20.04.1) ...
Setting up libnvidia-compute-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up libnvidia-extra-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-utils-470 (470.63.01-0ubuntu0.20.04.2) ...
Setting up libnvidia-fbc1-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-compute-utils-470 (470.63.01-0ubuntu0.20.04.2) ...
Warning: The home dir /nonexistent you specified can't be accessed: No such file or directory
Adding system user `nvidia-persistenced' (UID 130) ...
Adding new group `nvidia-persistenced' (GID 139) ...
Adding new user `nvidia-persistenced' (UID 130) with group `nvidia-persistenced' ...
Not creating home directory `/nonexistent'.
Setting up libnvidia-cfg1-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up libnvidia-common-470 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-kernel-common-470 (470.63.01-0ubuntu0.20.04.2) ...
update-initramfs: deferring update (trigger activated)
update-initramfs: Generating /boot/initrd.img-5.4.0-84-generic
Created symlink /etc/systemd/system/systemd-hibernate.service.requires/nvidia-hibernate.service → /lib/systemd/system/nvidia-hibernate.service.
Created symlink /etc/systemd/system/systemd-suspend.service.requires/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-hibernate.service.requires/nvidia-resume.service → /lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-suspend.service.requires/nvidia-suspend.service → /lib/systemd/system/nvidia-suspend.service.
Setting up libnvidia-gl-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up libnvidia-gl-470:i386 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-settings (465.19.01-0ubuntu1) ...
Setting up libnvidia-decode-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up xserver-xorg-video-nvidia-470 (470.63.01-0ubuntu0.20.04.2) ...
Setting up libnvidia-ifr1-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
Setting up nvidia-dkms-470 (470.63.01-0ubuntu0.20.04.2) ...
update-initramfs: deferring update (trigger activated)
update-initramfs: Generating /boot/initrd.img-5.4.0-84-generic
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
Loading new nvidia-470.63.01 DKMS files...
Building for 5.4.0-84-generic 5.4.0-88-generic
Building for architecture x86_64
Building initial module for 5.4.0-84-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-source-470.0.crash'
Error! Bad return status for module build on kernel: 5.4.0-84-generic (x86_64)
Consult /var/lib/dkms/nvidia/470.63.01/build/make.log for more information.
dpkg: error processing package nvidia-dkms-470 (--configure):
 installed nvidia-dkms-470 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-470:
 nvidia-driver-470 depends on nvidia-dkms-470 (<= 470.63.01-1); however:
  Package nvidia-dkms-470 is not configured yet.
 nvidia-driver-470 depends on nvidia-dkms-470 (>= 470.63.01); however:
  Package nvidia-dkms-470 is not configured yet.

dpkg: error processing package nvidia-driver-470 (--configure):
 dependency problems - leaving unconfigured
Setting up libnvidia-encode-470:amd64 (470.63.01-0ubuntu0.20.04.2) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu2) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-88-generic
Errors were encountered while processing:
 nvidia-dkms-470
 nvidia-driver-470
E: Sub-process /usr/bin/dpkg returned an error code (1)

Am I doing something obviously wrong, is there a workaround, or is this something that will be fixed in the future?

Many thanks and best regards

make.log (359.8 KB)

Can you post (attach) that file here please.
Just to make sure, do you have the kernel headers installed? Package linux-headers-$(uname -r).

I have attached the file to my original post. The headers seem fine to me:

$ apt list --installed | grep 'linux-headers-'
linux-headers-5.4.0-84-generic/focal-updates,focal-security,now 5.4.0-84.94 amd64 [installed,automatic]
linux-headers-5.4.0-84/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0-84.94 all [installed,automatic]
linux-headers-5.4.0-86-generic/focal-updates,focal-security,now 5.4.0-86.97 amd64 [installed,automatic]
linux-headers-5.4.0-86/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0-86.97 all [installed,automatic]
linux-headers-5.4.0-88-generic/focal-updates,focal-security,now 5.4.0-88.99 amd64 [installed,automatic]
linux-headers-5.4.0-88/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0-88.99 all [installed,automatic]
linux-headers-generic/focal-updates,focal-security,now 5.4.0.88.92 amd64 [installed,automatic]
$ uname -r
5.4.0-84-generic

What compiler are you using?
Should be the same the kernel was built. Find that out with:
cat /proc/version
Then look at your system settings:
update-alternatives --display cc
update-alternatives --display c++

Post all the commands output here.

Thanks, you are right - kernel headers were built with gcc but the defaults for cc/c++ had been switched to clang.

Hi
How did you change the c++ compiler then?

These lines let you select your system’s default compilers, where ‘default compilers’ are whatever the cc and c++ programs point to. For ubuntu 20.04 LTS it should be gcc.

sudo update-alternatives --config cc
sudo update-alternatives --config c++