I tried to install CUDA 11.7 tookit on Ubuntu 22.04.3 LTS. I followed the steps on NVIDIA website:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-ubuntu2204-11-7-local_11.7.0-515.43.04-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-11-7-local_11.7.0-515.43.04-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
However, I failed at the last step. It returned:
Error! Bad return status for module build on kernel: 6.2.0-26-generic (x86_64)
Consult /var/lib/dkms/nvidia/515.43.04/build/make.log for more information.
And the information in make.log was:
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-11 (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
You are using: x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Since I am a green hand of Linux, I guess what led to this failure is that my gcc is too new. So I tried to install gcc-11.3.0, and I used command like this:
sudo apt-get install gcc-11.3
But the terminal returned:
E: Unable to locate package gcc-11.3
E: Couldn't find any package by glob 'gcc-11.3'
E: Couldn't find any package by regex 'gcc-11.3'
Since most other similar questions are years ago, they have little help for me. Now I have no idea what should I do. Any suggestions? I would very appreciate it if you can tell me the details, or you can point what causes the problem actually.