Nvidia driver could not be installed in ubuntu 20.04

I have been using the nvidia-driver-545, for some time, and it was working fine. But recently I wanted to change my graphics from hybrid to discrete in the BIOS, so I did and it did work.

But once I reverted back to hybrid mode in bios, my external monitor does not work, and nvidia-smi could not connect to the GPU.

Laptop- HP OMEN,
GPU - RTX 3060,
Ubuntu - 20.04

I’ve tried reinstalling the driver, but I’m facing the following error while installing the driver.

Setting up nvidia-dkms-545 (545.23.06-0ubuntu1) ...
update-initramfs: deferring update (trigger activated)

A modprobe blacklist file has been created at /etc/modprobe.d to prevent Nouveau
from loading. This can be reverted by deleting the following file:
/etc/modprobe.d/nvidia-graphics-drivers.conf

A new initrd image has also been created. To revert, please regenerate your
initrd by running the following command after deleting the modprobe.d file:
`/usr/sbin/initramfs -u`

*****************************************************************************
*** Reboot your computer and verify that the NVIDIA graphics driver can   ***
*** be loaded.                                                            ***
*****************************************************************************

INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
Removing old nvidia-545.23.06 DKMS files...

------------------------------
Deleting module version: 545.23.06
completely from the DKMS tree.
------------------------------
Done.
Loading new nvidia-545.23.06 DKMS files...
Building for 5.15.0-107-generic
Building for architecture x86_64
Building initial module for 5.15.0-107-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-source-545.0.crash'
Error! Bad return status for module build on kernel: 5.15.0-107-generic (x86_64)
Consult /var/lib/dkms/nvidia/545.23.06/build/make.log for more information.
dpkg: error processing package nvidia-dkms-545 (--configure):
 installed nvidia-dkms-545 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-545:
 nvidia-driver-545 depends on nvidia-dkms-545 (= 545.23.06-0ubuntu1); however:
  Package nvidia-dkms-545 is not configured yet.

dpkg: error processing package nvidia-driver-545 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-107-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=bdd292c9-2920-449f-be48-f12a0a173949)
I: Set the RESUME variable to override this.
Errors were encountered while processing:
 nvidia-dkms-545
 nvidia-driver-545
E: Sub-process /usr/bin/dpkg returned an error code (1)

According to this, I’ve checked that my selected version of gcc is the same as the one used to compile the kernel. But I do get the error. Kindly help. Attached images for your reference. Do let me know if you need anything else.

Hi there,

When switching back from discrete GPU only to hybrid mode it is recommended to do a clean re-install. Which means purging first, rebooting and then install again. It looks like your package manager has some deadlock, so that needs clean-up first.

I can’t say from the above what the kernel actually did to break things after switching, but likely something to do with device discovery and boot order.

Also please check out this post:

Hi Markus, Many thanks to you.

After following your advice, I was able to install the driver using the .run installer.

Steps I followed.

  1. Purge any existing nvidia files.
sudo apt-get remove --purge '^nvidia-.*'
  1. Reboot.
  2. Install the driver using the .run installer.

Commands referred from this thread.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.