NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver

I have a Lenovo Legion Pro 5 16IRX9 with Intel ® Core ™ i9-14900HX × 32 and RTX4070 of 8gb. I tried with the following drivers:

nvidia-conductor-570
nvidia-conductor-565
nvidia-conductor-550
nvidia-conductor-545
nvidia-conductor-535

but doing nvidia-smi I 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.

I have also tried many suggestions in similar forum posts but without success.
In addition to this, I can’t even connect a second monitor as it doesn’t recognize it. Do you have any suggestions?
Processing: nvidia-bug-report.log.gz…

Do you have secure boot enabled. If so make sure you’ve enrolled the MOK appropriately or disable secureboot entirely. Also it might be a good idea to include steps you’ve already tried and their outcome.

For MOK enrollment use:

sudo mokutil --import /usr/share/nvidia-pubkeys/<nvidia-driver>.der
You will be asked for a password. Memorize it! it is important later on. Use something which is easy to memorize and preferably does not include any special characters as I don’t know which keyboard layout your BIOS will assume. Maybe only stick with numbers.

Note: That different Linux distributions tend to put these key files in different locations. If you can’t find them maybe search for

nVidia secureboot MOK enrollment YOUR DISTRO

or similar online.

Then reboot the computer and your UEFI should display an appropriate dialogue to finally import the MOK. If asked choose “Enroll MOK” or similar. Then “Continue”. Answer the “Enroll MOK keys” with yes. Finally enter the password you have chosen earlier.

Here is the wiki of openSUSE they have a very sophisticated troubleshooting about this. You may need to adapt a few steps according to your distro though. SDB:NVIDIA drivers - openSUSE Wiki

You are right! Secure boot is enabled. I’m going to try that and I’ll let you know.
I have also tried what is recommend here as I need to install Isaac Sim V4.5. However I have also had problems with the kernel trying to follow the installation steps. I guess it has to do with the same thing you mention.) as I need to install Nvidia Isaac Sim v4.5. However I have also had problems with the kernel trying to follow the installation steps. I guess it has to do with the same thing you mention.
I will update this post after trying. Thank you!

Update: I have completely deactivated the secure boot from the bios and exactly followed these steps, but I’m still not able to properly install the last Nvidia drivers.

Logs here:
nvidia-installer.log (186.5 KB)

Hm, I am not an Ubuntu expert. But looking at the log I’d suggest to install gcc-12. As it seems the driver tries to build the kernel module with cc 11 instead. (notice the missing g and the lower version). Which seems to lead to these errors:

Warning: Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38

does not match the compiler used here:

cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

and later during the build attempt:

cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’

Therefore my first attempt would be to install gcc 12 and then try again.

Sorry for the delay in the response.I also tried installing gcc 12 but I’m still not able to get the nvidia drivers. I’ll try again tonight from scratch and save the command history so I can share it in case it fails. Thanks!