An error occurred while performing the step: “Building kernel modules”. See varlog/nvidia-installer.log for details

I have been trying to install the NVIDIA-Linux-x86_64-525.78.01.run on the TU117M [GeForce GTX 1650 Mobile / Max-Q] on a Ubuntu 22.04 but I have been having issues of incompatibility with previous installations of the driver.

I even tried purging old installed drivers using:
dpkg -l | grep nvidia
sudo dpkg -P ‘nvidia-dkms-515’
etc

Still however the kernel build fails every time.

The nvidia-installer.log can be read here:

Please help!
Thank you :)

P.S.: When using Software & Updates to install version 525 I still get this error:
Imgur

Here’s what dpkg -l | grep nvidia currently prints out:
Imgur

You have set gcc 9 as system compiler but the standard compiler of ubuntu 22.04 should be gcc 11.

Hello! Thank you, but I get this error when installing gcc11 following this tutorial:

hugo@hugo-pc:~$ sudo -i

root@hugo-pc:~# apt install build-essential

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

build-essential is already the newest version (12.9ubuntu3).

build-essential set to manually installed.

0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

1 not fully installed or removed.

After this operation, 0 B of additional disk space will be used.

Do you want to continue? [Y/n] y

Setting up nvidia-dkms-525 (525.60.13-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-525.60.13 DKMS files…

Deleting module nvidia-525.60.13 completely from the DKMS tree.

Loading new nvidia-525.60.13 DKMS files…

Building for 5.15.0-57-generic

Building for architecture x86_64

Building initial module for 5.15.0-57-generic

ERROR: Cannot create report: [Errno 17] File exists: ‘/var/crash/nvidia-dkms-525.0.crash’

Error! Bad return status for module build on kernel: 5.15.0-57-generic (x86_64)

Consult /var/lib/dkms/nvidia/525.60.13/build/make.log for more information.

dpkg: error processing package nvidia-dkms-525 (–configure):

installed nvidia-dkms-525 package post-installation script subprocess returned error exit status 10

Processing triggers for initramfs-tools (0.140ubuntu13.1) …

update-initramfs: Generating /boot/initrd.img-5.15.0-57-generic

Errors were encountered while processing:

nvidia-dkms-525

E: Sub-process /usr/bin/dpkg returned an error code (1)

root@hugo-pc:~# sudo apt -y install gcc-11

Reading package lists… Done

Building dependency tree… Done

Reading state information… Done

gcc-11 is already the newest version (11.3.0-1ubuntu1~22.04).

gcc-11 set to manually installed.

0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

1 not fully installed or removed.

After this operation, 0 B of additional disk space will be used.

Setting up nvidia-dkms-525 (525.60.13-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-525.60.13 DKMS files…

Deleting module nvidia-525.60.13 completely from the DKMS tree.

Loading new nvidia-525.60.13 DKMS files…

Building for 5.15.0-57-generic

Building for architecture x86_64

Building initial module for 5.15.0-57-generic

ERROR: Cannot create report: [Errno 17] File exists: ‘/var/crash/nvidia-dkms-525.0.crash’

Error! Bad return status for module build on kernel: 5.15.0-57-generic (x86_64)

Consult /var/lib/dkms/nvidia/525.60.13/build/make.log for more information.

dpkg: error processing package nvidia-dkms-525 (–configure):

installed nvidia-dkms-525 package post-installation script subprocess returned error exit status 10

Processing triggers for initramfs-tools (0.140ubuntu13.1) …

update-initramfs: Generating /boot/initrd.img-5.15.0-57-generic

Errors were encountered while processing:

nvidia-dkms-525

E: Sub-process /usr/bin/dpkg returned an error code (1)

root@hugo-pc:~# sudo update-alternatives --config gcc

update-alternatives: error: no alternatives for gcc