NVIDIA 驱动程序随机未找到 - 重新安装时“构建内核模块”失败

NVIDIA 驱动程序随机未找到 - 重新安装时“构建内核模块”失败

我正在运行带有 GTX 1070 的 Ubuntu 16.04。我使用这台机器运行 Tensorflow,并启用了 GPU 支持。前几天我随机重启了系统,现在无法登录。我可以进入登录屏幕,输入密码,但随后它会将我引导回登录屏幕。但是,我可以通过 Alt+Ctrl+F1 进入命令行。

当我尝试从源代码安装任何驱动程序时(我认为驱动程序版本并不重要,因为我已经尝试了几个不同的版本),我收到错误:

ERROR: An error occurred while performing the step: "Building kernel modules". See /var/log/nvidia-installer.log for details进而The NVIDIA kernel module was not created

我尝试过从源代码卸载sudo ./NVIDIA-Linux-x86_64-367.57-no-compat32.run --uninstall,然后从源代码重新安装,但还是一样。我尝试过从源代码更新,sudo ./NVIDIA-Linux-x86_64-367.57-no-compat32.run --update但还是一样。

我尝试过从 PPA 安装:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367

这并没有完全失败,但它再次输出与内核相关的错误:Error! Bad return status for module build on kernel: 4.4.0-53-generic

这是我在 PPA 安装后检查驱动程序时得到的结果:

$ nvidia-smi
modprobe: ERROR ../libkmod/libkmod-module.c:832 kmod_module_insert_module() could not find module by name='nvidia_367'
modprove: ERROR could not insert 'nvidia_367': unknown symbol in module, or unknown parameter (see dmesg)
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Maker sure that the latest NVIDIA diver is installed and running.

这可能是 CUDA 问题吗?如果是,我该如何修复它?

我是否应该重新安装操作系统(全新安装且不丢失数据)?

更新

我知道是什么导致了这个问题,但我不知道如何解决它。

大约一周前,我将默认编译器更改为clang,我认为 NVIDIA 驱动程序需要gccg++。我不确定如何将其改回来(同事更改了它)。我试过了,ln -s /usr/bin/gcc-4.9 ~/.local/bin/gcc但没有用。

bug 提到了指向 clang 的配置文件指针,但没有确切告诉我如何将其指回。我怎样才能将配置文件指回gcc

答案1

原来是编译器问题。我相信我已经clang将其设置为默认编译器。我按照这里Ubuntu 现在可以正常看到我的 NVIDIA 驱动程序了。

相关内容