NVIDIA driver 535 broken when updating on Ubuntu 22.04

A few days ago right after a system update to kernel 6.5 on Ubuntu 22.04, my second monitor was no longer working due to a broken Nvidia driver :

I had to upgrade gcc to version 12 so that I could be able to install the latest  NVIDIA driver 535 (propietary).

I used the following commands to fix this:

sudo mv /usr/bin/gcc /usr/bin/gcc-11
sudo ln /usr/bin/gcc-12 /usr/bin/gcc
sudo apt install nvidia-driver-535 nvidia-dkms-535