NVIDIA driver 515.43.04 fails to load on Ubuntu, MSI GS66 with RTX 2070


nvidia-smi throws 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 tried installing the 515 drivers like so:
apt purge '*nvidia*'
apt autoremove
apt autoclean
apt install --reinstall linux-headers-$(uname -r)
I rebooted at this point, then:
apt install nvidia-driver-515
And another reboot. I also tried different versions of the drivers, with the same result.

Performing prime-select nvidia with update-initramfs -u leads to a blank screen on the next boot.

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

I tried reading the bug report myself, to no avail. Oh, and it mentions that

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
  You are using:           cc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

but (I think) that’s a false positive, the cc is a symlink to gcc-11.

sudo prime-select on-demand
get you a working system?

It does! With on-demand, nvidia-smi works as expected.
Thank you.

Please delete
the intel driver is not recommended, likely the cause prime-select nvidia doesn’t work.

Oh nice, that was it! Now everything seems to work perfectly, thank you very much.