For any one who encounters the same error you should install GCC 12 instead of GCC 11 which is default on Ubuntu 22.04. Follow the Medium 2 steps on this page:
And now Installation of drivers for Geforce RTX 4090. I noticed that your drivers include cuda toolkit 12.2 so I found a page describing the installation steps for laptop version of Geforce RTX 4080. So, I hope the driver is going to suport the desktop version of RTX 4090 as well since desktop RTX4090 is in the list of supported devices for driver version 535.171.04: