Bad return status for module build on kernel: 5.4.0-42-generic on Ubuntu18.04. NVIDIA-SMI failed (nvidia-driver-435)

Hi, I need some desperate help here! I am trying to fix the Nvidia driver with version 435.21 on my Ubuntu 18.04 system, yet have trouble trying to link the kernel to the nvidia driver:

After running

sudo apt install --reinstall linux-headers-5.4.0-42-generic

I got

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 1,274 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://sg.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.4.0-42-generic amd64 5.4.0-42.46~18.04.1 [1,274 kB]
Fetched 1,274 kB in 2s (799 kB/s)                         
(Reading database ... 325382 files and directories currently installed.)
Preparing to unpack .../linux-headers-5.4.0-42-generic_5.4.0-42.46~18.04.1_amd64.deb ...
Unpacking linux-headers-5.4.0-42-generic (5.4.0-42.46~18.04.1) over (5.4.0-42.46~18.04.1) ...
Setting up linux-headers-5.4.0-42-generic (5.4.0-42.46~18.04.1) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-42-generic

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
unset ARCH; env NV_VERBOSE=1 'make' -j8 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.4.0-42-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.4.0-42-generic/build LD=/usr/bin/ld.bfd modules........(bad exit status: 2)
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-dkms-435.0.crash'
Error! Bad return status for module build on kernel: 5.4.0-42-generic (x86_64)
Consult /var/lib/dkms/nvidia/435.21/build/make.log for more information.
   ...done.

This is the make.log file:
make.log (342.6 KB)

Before this, I installed the 435.21 driver using software&updates directly after purging nvidia* and cuda*, yet after reboot, I got llvmpipe (LLVM 10.0.0, 256 bits) running my graphic card and the following:

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

$nvidia-settings
ERROR: NVIDIA driver is not loaded
ERROR: Unable to load info from any available system

$lshw -C display
  *-display UNCLAIMED       
       description: VGA compatible controller
       product: GM204GL [Quadro M4000]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list
       configuration: latency=0
       resources: memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:e000(size=128) memory:f7000000-f707ffff

$dkms status
nvidia, 435.21: added

I have tried:

sudo apt-get install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04

and got

Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-generic-hwe-18.04 is already the newest version (5.4.0.42.46~18.04.35).
xserver-xorg-hwe-18.04 is already the newest version (1:7.7+19ubuntu8~18.04.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

as well as

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

and got

Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-5.4.0-42-generic is already the newest version (5.4.0-42.46~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

nvidia-bug-report.log.gz (113.2 KB)

I just have a hunch there is definitely something wrong with my kernel, but have no idea how to fix it. I do not have /etc/modprobe.d/blacklist-nvidia.conf on my computer.

Can someone please help me with this? Any help would be highly appreciated.

I noticed that the secure boot was enabled on my system previously, so I have disabled it and redo the whole reinstallation procedure, with no luck still.

Attached my new nvidia-bug-report.log
nvidia-bug-report.log.gz (102.6 KB)

@generix Hi, could you please take a look at my issue, thanks a bunch in advance!

I seem to be having the same issue for 5.4.0-42-generic on Ubuntu18.04 for nvidia-driver-435. Attached is my bug report log. nvidia-bug-report.log.gz (136.2 KB)

I’ve had a similar problem on the 5.4.0 kernel and steps from this comment helped.

Finally fixed this. I really couldn’t nvidia-driver-435 to work on this kernel version so i searched for others who have an issue and found that 440 worked for some. So I did the following steps:

sudo apt-get autoremove --purge nvidia-*
sudo apt-get autoremove --purge nvidia-driver-435
sudo apt-get install --reinstall linux-headers-$(uname -r)
sudo apt-add-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-driver-440
reboot

This successfully installed 440 and now my drivers can detect my GPU.

1 Like

I just switched back to the old kernel 5.3.0-62-generic instead of 5.4.0.xxx by editing /etc/default/grub to let me choose a kernel on startup.
It also works and one never needs a kernel update anyway.
From experience: Reinstalling / purging nvidia-drivers might lead to the infamous ubuntu login loop, which in can be really hard to fix