Can't use nvidia-drivers on Ubuntu 22.04 with Geforce 940M (Zenbook UX303)

Okay, I need to update my first post. Seeing some strange nvidia leftover package, I tried to remove it and did 2 other tentatives:

  1. manually install the 470 on 4.5 and 4.2 kernels
  2. ubuntu official method with 535 and the same kernels

With both, I can’t boot on the 4.5 kernel but it works with 4.2 kernel.

nvidia-driver-470

nvidia-settings warned me about this:

ERROR: nvidia-settings could not find the registry key file or the X server is not accessible. This file should have been installed along with this driver at
       /usr/share/nvidia/nvidia-application-profiles-key-documentation. The application profiles will continue to work, but values cannot be prepopulated or validated, and will not be listed in the help text.
       Please see the README for possible values and descriptions.

I followed this solution: ERROR: nvidia-settings could not find the registry key file - #3 by geoffrey.hoffman

There is a strange message but it seems okay (see: PRIME not supported after installing nvidia-driver-470 for Ubuntu 20.04 LTS):

$ nvidia-settings
[...]
** Message: 10:19:04.177: PRIME: No offloading required. Abort
** Message: 10:19:04.177: PRIME: is it supported? no
$ nvidia-smi
Failed to initialize NVML: Driver/library version mismatch

Well in /var/log/kern.log I got:

Mar 25 10:16:09 Noisette kernel: [  377.287961] NVRM: API mismatch: the client has the version 470.239.06, but
Mar 25 10:16:09 Noisette kernel: [  377.287961] NVRM: this kernel module has the version 470.223.02.  Please
Mar 25 10:16:09 Noisette kernel: [  377.287961] NVRM: make sure that this kernel module and all NVIDIA driver
Mar 25 10:16:09 Noisette kernel: [  377.287961] NVRM: components have the same version.

I tried this

sudo dkms remove nvidia/470.239.06 --all
sudo dkms --force install nvidia/470.239.06 -k 6.2.0-39-generic

But even after a reboot, the same error appears.

nvidia-bug-report.470.log.gz (136.3 KB)

nvidia-driver-535

With the ubuntu-drivers tool, this is what 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.

nvidia-bug-report.535.log.gz (111.9 KB)