问题
嗨,我在计算机上安装 Nvidia 驱动程序时遇到了问题。目标是执行以下简单命令:
$ ubuntu-drivers devices
因此,得到如下结果:
modalias : pci:v000010DEd00001C8Csv00001028sd00000798bc03sc00i00
vendor : NVIDIA Corporation
model : GP107M [GeForce GTX 1050 Ti Mobile]
driver : nvidia-driver-460 - distro non-free
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-470 - distro non-free recommended
driver : nvidia-driver-450-server - distro non-free
driver : nvidia-driver-460-server - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
检查一切正常后,只需运行以下命令:
$ sudo ubuntu-drivers autoinstall
但是我在输出中得到了这个响应ubuntu-drivers devices
,因此无法执行下一步sudo ubuntu-drivers autoinstall
:
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
重要的提示直到今天,驱动程序都运行正常。但在笔记本电脑没电后(因此关机),驱动程序不知为何消失了。我使用的驱动程序以及我将尝试安装的驱动程序是 Nvidia 的 470,也就是说,我从未安装过 390。
我已经尝试过的解决方案
我尝试过几种解决方案,但都没有效果,比如一个简单的
$ sudo apt update
$ sudo apt upgrade
$ sudo ubuntu-drivers autoinstall
但它不起作用,然后我尝试
$ sudo apt-get remove --purge nvidia*
$ sudo ubuntu-drivers autoinstall
也不起作用,我也试过用引号
$ sudo apt-get remove --purge "nvidia*"
$ sudo ubuntu-drivers autoinstall
但它总是失败
我的配置
Ubuntu 版本
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
内核版本
$ uname -a
Linux DellInspiron 5.11.0-34-generic #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
驱动程序列表
$ ubuntu-drivers list
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
nvidia-driver-450-server, (kernel modules provided by linux-modules-nvidia-450-server-generic-hwe-20.04)
nvidia-driver-460-server, (kernel modules provided by linux-modules-nvidia-460-server-generic-hwe-20.04)
nvidia-driver-390, (kernel modules provided by linux-modules-nvidia-390-generic-hwe-20.04)
nvidia-driver-418-server, (kernel modules provided by linux-modules-nvidia-418-server-generic-hwe-20.04)
nvidia-driver-470, (kernel modules provided by linux-modules-nvidia-470-generic-hwe-20.04)
nvidia-driver-460, (kernel modules provided by linux-modules-nvidia-460-generic-hwe-20.04)
设备列表
$ ubuntu-drivers devices
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C8Csv00001028sd00000798bc03sc00i00
vendor : NVIDIA Corporation
model : GP107M [GeForce GTX 1050 Ti Mobile]
driver : nvidia-driver-460 - distro non-free
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-470 - distro non-free recommended
driver : nvidia-driver-450-server - distro non-free
driver : nvidia-driver-460-server - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
答案1
在多个论坛上研究后,我找到了部分解决方案这里由用户 alok.fj 发布
步骤很简单,我把所有步骤按顺序列在这里:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt autoremove
$ sudo apt-get remove --purge nvidia*
$ sudo apt-get remove --purge "nvidia*"
然后我跑了(就像原来的想法一样)
$ ubuntu-drivers devices
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
modalias : pci:v000010DEd00001C8Csv00001028sd00000798bc03sc00i00
vendor : NVIDIA Corporation
model : GP107M [GeForce GTX 1050 Ti Mobile]
driver : nvidia-driver-460 - distro non-free
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-470 - distro non-free recommended
driver : nvidia-driver-450-server - distro non-free
driver : nvidia-driver-460-server - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
请注意,我仍然收到警告,但不是运行,而是运行明确说明所需驱动程序版本的命令:sudo ubuntu-drivers autoinstall
sudo apt install nvidia-driver-470
sudo reboot
重新启动后,请使用以下命令测试安装nvidia-smi
,您应该得到如下结果:
$ nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.57.02 Driver Version: 470.57.02 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| N/A 50C P0 N/A / N/A | 447MiB / 4040MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
...
TL; DR
$ sudo apt update
$ sudo apt upgrade
$ sudo apt autoremove
$ sudo apt-get remove --purge nvidia*
$ sudo apt-get remove --purge "nvidia*"
$ sudo apt install nvidia-driver-470 (you may need other version)
$ sudo reboot
测试
$ nvidia-smi
答案2
我尝试了所有这些步骤,但根本问题是安全启动已启用。禁用安全启动完成了工作。