NVIDIA驱动

如果你现在要做的事和NVIDIA显卡有关,一定先检查,显卡驱动是否正常

打开命令行
输入
nvidia-smi

nvidia-smi

输出了一个表格,表示正常,中间那栏表示显卡使用情况,比如这张图的9137MiB / 12288MiB。

除此自外可能会有的报错

nvidia-smi no devices were found

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make
sure that the latest NVIDIA driver is installed and running.

没有nvidia这个指令

解决

大部分情况只需要按照要求重装显卡驱动即可

#使用该命令查看显卡推荐
ubuntu-drivers devices

#自动安装推荐的线控器驱动
sudo ubuntu-drivers autoinstall

#也可以自行选择
#sudo apt install nvidia-driver-440

#重启电脑
sudo reboot

figure 2

安装完显卡驱动后,会出现上图的“configuring secure boot”,确定之后,设置一个安全启动密码,以前设置过的可能就不会有,一定不可以忘记,后续要用。系统需要重启加载驱动,在重启系统时:会出现一个,蓝色背景的界面perform mok management 后,选择 enroll mok,进入enroll mok 界面,选择 continue,进入enroll the key 界面,选择 yes,接下来输入你在安装驱动时输入的密码,之后会跳到蓝色背景的界面perform mok management 选择第一个 reboot
重启后,打开终端,再次输入nvidia-smi 检查是否成功

报错为

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make 
sure that the latest NVIDIA driver is installed and running. This can also be
happening if non-NVIDIA GPU is running as primary display, and NVIDIA GPU is in
WDDM mode.

可能为显卡驱动损坏,考虑重装

sudo apt-get --purge remove nvidia-*
sudo apt autoremove
sudo ubuntu-drivers install