我尝试在 Ubuntu 22.04.3 LTS 上安装 CUDA 11.7。我按照 NVIDIA 网站上的步骤进行操作:
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
然而,最后一步我失败了。它返回:
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.
并且信息生成日志曾是:
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
由于我是 Linux 的新手,我猜导致此失败的原因是我的 gcc太新了。所以我尝试安装 gcc-11.3.0,我使用了如下命令:
sudo apt-get install gcc-11.3
但终端返回:
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'
由于大多数其他类似问题都是几年前的,所以它们对我帮助不大。现在我不知道该怎么办。有什么建议吗?如果您能告诉我详细信息,或者指出问题的实际原因,我将不胜感激。