文章目录

  • ​​问题描述​​
  • ​​测试​​
  • ​​问题原因​​
  • ​​解决方法​​
  • ​​禁止内核更新​​
  • ​​更改启动项选择​​
  • ​​修改启动选项​​
  • ​​更新GRUB​​
  • ​​重启​​
  • ​​卸载内核​​

问题描述

  • 外接显示器无反应;
  • 输入​​nvidia-smi​​发现报错:

测试

重启电脑, 在ubuntu 启动过程中选择​​Advanced options for Ubuntu​​的低版本版本运行。

输入:

nvidia-smi

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._ubuntu

发现是正常的,同时外接显示器也能正常显示。

问题原因

NVIDIA驱动是在低版本的时候安装,由于系统更新,内核版本升级导致NVIDIA无法应用在高内核版本.

解决方法

查看自己电脑中的内核:

dpkg --get-selections | grep linux

我这里有三个内核,每个内核都有四个小部分。

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._Ubuntu_02


查看当前版本的内核号:

uname -r

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._ubuntu_03

禁止内核更新

  • ​​ubuntu禁止自动更新内核​​
sudo apt-mark hold linux-image-5.4.0-84-generic
sudo apt-mark hold linux-headers-5.4.0-84-generic
sudo apt-mark hold linux-modules-5.4.0-84-generic
sudo apt-mark hold linux-modules-extra-5.4.0-84-generic

更改启动项选择

查看内核启动选项:

cat /boot/grub/grub.cfg | grep menuentry

我们想要的​​5.4.0-84-generic​​是在第三位:

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._Ubuntu_04


说明:

  • ​menuentry(主菜单)​​​: 默认启动内核。 为0, 对应 ​​/etc/default/grub​​ 中 GRUB_DEFAULT=0 的0。
  • ​submenu(子菜单)​​​: 包含所有启动内核。 为1 对应 ​​/etc/default/grub​​​ 中 ​​GRUB_DEFAULT=“1> 2"​​的1。其中menuentry所对应的索引从0开始。

修改启动选项

sudo gedit /etc/default/grub

找到​​GRUB_DEFAULT=0​​:

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._Ubuntu_05

修改为你所想要还原的版本号:(只用更改最后的即可)

# GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu,Linux 5.4.0-84-generic"
GRUB_DEFAULT="1>2"

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._Ubuntu_06

更新GRUB

sudo update-grub

Ubuntu18.04——问题解决:外接显示器无反应 且 NVIDIA-SMI has failed because it couldn‘t communicate ....._重启_07


如果底下有warning,就按他说的改一下,我这里是:

Advanced options for Ubuntu>Ubuntu,Linux 5.4.0-84-generic

重启

sudo reboot

卸载内核

卸载最新的内核:

sudo apt-get remove \
linux-headers-5.4.0-100-generic \
linux-image-5.4.0-100-generic \
linux-modules-5.4.0-100-generic \
linux-modules-extra-5.4.0-100-generic

参考文章: