Broken driver install after upgrade to ubuntu 22.04 - dkms build fail for 390.157 for Imac

Hello !
I upgraded from elementary OS 6 to 7.1 by updating sources to ubuntu 22.04, everything works (had similar issue with wifi) but the graphic card is not using the nvdia drivers recommended for that model, 390.157. The nouveau driver works fine but not using the OpenGL, so some programs get sloppy.

Before upgrade, drivers were in the 390.1xx range, and the 390.157 seems to be the latest driver for my GTX 680MX (on iMac 27’ 13,2)

What seem to be the main problem is when the install buids the dkms module : " Error! Bad return status for module build on kernel: 6.5.0-14-generic (x86_64) Consult /var/lib/dkms/nvidia/390.157/build/make.log → make.log (66.5 KB)

Some context :
nvidia-bug-report.log (666.0 KB)

Xorg.0.log (193.8 KB)

sudo 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.

inxi -G
Graphics:
Device-1: NVIDIA GK104M [GeForce GTX 680MX] driver: nouveau v: kernel
Device-2: Apple FaceTime HD Camera (Built-in) type: USB driver: uvcvideo
Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: modesetting
unloaded: fbdev,intel,vesa failed: nvidia gpu: nouveau resolution:
1: 2560x1440~60Hz 2: 1920x1080~60Hz
OpenGL: renderer: N/A v: N/A

modprobe nvidia
modprobe: FATAL: Module nvidia not found in directory /lib/modules/6.5.0-14-generic

dkms status
bcmwl/6.30.223.271+bdcom, 6.5.0-14-generic, x86_64: installed
nvidia/390.157: added

Hoping anyone has some hint to throw :)

The 390 driver is out of support and won’t compile against kernel 6.5 but the correct driver for your gpu is 470 anyway.
If you have issues with that one, please see this:
https://forums.developer.nvidia.com/t/driver-install-fails-with-the-error-an-error-occurred-while-performing-the-step-building-kernel-modules-see-var-log-nvidia-installer-log/280385/2?u=generix

Thank you so much for that swift and hopeful reply !

I indeed had to install GCC 12 while moving on the driver solution, but now I see it might have been why it failed after dist-upgrade and automatic install of the 470 driver( suggested by the App Center too), giving me no gui session nor wifi :)

For some reason I was suggested the 390 by the search drop down menus on driver download support page. Just rechecked now and it now leads me toward 418, go figure…

I can’t see my GeForce GTX 680M on the supported list of the 470 (although GeForce GTX 680 is) but I will take your word to try it :)