Problem installing NVIDIA driver 440 on Ubuntu 20.04

I have a dual-boot setup with Windows 10 and Ubuntu 20.04. I was originally using the NVIDIA driver 440 with CUDA on Ubuntu with no issues. I then installed the NVIDIA driver for Windows (version 452.06) and accidentally selected clean installation in the Custom install options. Everything works fine in the Windows side, but on the Ubuntu side, I ran nvidia-smi and got the following error:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

I then removed the NVIDIA driver packages with:

$ sudo dpkg -P $(dpkg -l | grep nvidia-driver | awk '{print $2}')
$ sudo apt autoremove
$ reboot

I also uninstalled and re-installed the NVIDIA driver version for Windows. I tried re-installing the driver for Ubuntu using:

$ sudo apt install nvidia-driver-440

but I get the following error:

Error! Bad return status for module build on kernel: 5.4.0-45-generic (x86_64)
Consult /var/lib/dkms/nvidia/450.66/build/make.log for more information.
dpkg: error processing package nvidia-dkms-450 (--configure):
 installed nvidia-dkms-450 package post-installation script subprocess returned 
error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-450:
 nvidia-driver-450 depends on nvidia-dkms-450 (<= 450.66-1); however:
  Package nvidia-dkms-450 is not configured yet.
 nvidia-driver-450 depends on nvidia-dkms-450 (>= 450.66); however:
  Package nvidia-dkms-450 is not configured yet.

dpkg: error processing package nvidia-driver-450 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup erro
r from a previous failure.
                          No apport report written because the error message ind
icates its a followup error from a previous failure.
                                                    dpkg: dependency problems pr
event configuration of nvidia-driver-440:
 nvidia-driver-440 depends on nvidia-driver-450; however:
  Package nvidia-driver-450 is not configured yet.

dpkg: error processing package nvidia-driver-440 (--configure):
 dependency problems - leaving unconfigured
Setting up libnvidia-gl-450:amd64 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-gl-450:i386 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-encode-450:amd64 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-encode-450:i386 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-gl-440:i386 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-ifr1-450:amd64 (450.66-0ubuntu0.20.04.1) ...
Setting up libnvidia-ifr1-450:i386 (450.66-0ubuntu0.20.04.1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
/sbin/ldconfig.real: /usr/local/cuda-10.1/targets/x86_64-linux/lib/
 is not a symbolic link

Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for initramfs-tools (0.136ubuntu6.2) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-45-generic
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I don’t know how to resolve this. Please help!

Update: I backed up my home folder and reinstalled Ubuntu 20.04 (without erasing option) and went into Recovery mode where I saw that there is an issue with dpkg. I selected the option to “fix broken packages” but it didn’t work and encountered an error. So I normal booted into Ubuntu and tried installing NVIDIA driver 440 via “Software & Updates > Additional Drivers”. It seemed to have installed the driver, but when I run nvidia-smi I still get:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

Update2: I rebooted into recovery mode to try and capture the error I got, and when I normal booted and checked nvidia-smi it seemed to be working properly. I ran a deep learning network as a test, and it ran as expected. Will boot into Windows to check if the driver is working properly and then boot back into Ubuntu to see if can still use the nvidia-smi. If I don’t update again within 72 hours, you can safely assume that my issue has been resolved.

1 Like

Also getting the same issue, I cannot install anything to ubuntu.

You can’t install anything, or just can’t install drivers? What error message do you get?

Update: My issue is not resolved! It turns out that when I train a deep learning network, my GPU is not used. I just got an error today saying:

Package: nvidia-kernel-source-440 440. 100-0ubuntu0.20.04.1: nvidia kernel module failed to build

When I looked at the full error report, under “DKMSBuildLog” it says:

Error: kernel configuration is invalid

Can someone help?

Okay, I think I resolved my issue by obtaining the correct kernel headers and development packages from here and doing the following:

$ sudo apt-get install linux-headers-$(uname -r)

It seems that my linux-headers, linux-image, and linux-modules were version 5.4.0-26 even though my kernel version was 5.4.0-45. Not sure if this was the issue. But my GPU is now running when I train the network. I will wait another few days to see if I get another error report.

Edit: Also, when I run dkms status, I get:

nvidia, 440.100, 5.4.0-45-generic, x86_64: installed

Wudup Munib94,

I managed to fix the issue my end.

  1. Downloaded the latest Nvidia drivers for Linux from the their website
  2. Remove the existing ones.
  3. Install the new ones.

Everything okay for you now?

I think so. I found out that when I reboot into Ubuntu, I am rebooting into a different kernel version which was giving me issues with the NVIDIA driver. I checked using uname -r.

So I reverted back to the Xorg Nouveau driver through Software & Updates > Additional Drivers. The GUI makes it easy and removes the previously installed NVIDIA driver files. I rebooted back into normal Ubuntu through Recovery mode using the default kernel version in the Grub menu under Advanced Options. I then ran
sudo apt-get install linux-headers-$(uname -r)
followed by sudo apt autoremove. I installed the NVIDIA driver under Additional Drivers (which installed without error messages that I previously got), and restarted.

I ran dkms status which gave me:
nvidia, 440.100, 5.4.0-45-generic, x86_64: installed

Additionally, nvidia-smi works as normal and I am able to train deep learning networks as expected.

Edit: Booting into Recovery mode and then normal booting was necessary for me otherwise I would get a black screen because the NVIDIA driver was not installed. My display is connected to the NVIDIA GPU.