欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ubuntu Command 'nvidia-smi' not found

程序员文章站 2022-03-05 20:30:07
...

ubuntu Command ‘nvidia-smi’ not found

确保是否有gpu

lspci | grep NVIDIA
01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)

如果按照某些方法,安装后系统进不了,可以使用recovery模式。

我按照ubuntu提示,安装nvidia驱动后,系统进不去了。按照https://www.lizenghai.com/archives/29726.html里的方法,通过进入recovery模式(可参考这里https://www.jianshu.com/p/0180575d2366),使用apt卸载也没用。最后通过dpkg -r nvidia-*卸载了。

亲测可用的方法

参考https://www.performatune.com/en/how-to-install-nvidia-driver-on-ubuntu-18-04-lts/

#1. Delete installed Nvidia drivers

sudo apt-get purge nvidia*

#2. Head to the following page to check the latest driver version:
https://www.nvidia.com/object/unix.html

#Linux x86_64/AMD64/EM64T
#Latest Long Lived Branch Version: 418.56

#3. Update your system

sudo apt-get update && apt-get upgrade

#3. Check the latest driver

ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001436sv0000103Csd00008275bc03sc00i00
vendor   : NVIDIA Corporation
model    : GM206GLM [Quadro M2200 Mobile]
driver   : nvidia-driver-418 - third-party free recommended
driver   : nvidia-driver-390 - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

#5. Install appropriate nvidia driver:

sudo ubuntu-drivers autoinstall

#6. Check if your system is using nouveau open source driver:

lsmod | grep nouveau

#If nouveau is in use, you need to disable it before reboot.
这里很重要,不然2个驱动(新装的驱动和nouveau)可能会引起系统无法进入。

#Nouveau disabling

[email protected]:/etc/modprobe.d# bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
[email protected]:/etc/modprobe.d# bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

[email protected]:/etc/modprobe.d# cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0

#7. Reboot

reboot

#8. Check your driver installation:

nvidia-smi

#or 

lsmod | grep nvidia

成功后如下

[email protected]:~>nvidia-smi 
Fri Mar 22 08:20:39 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.43       Driver Version: 418.43       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M2200        Off  | 00000000:01:00.0  On |                  N/A |
| N/A   45C    P0    N/A /  N/A |   1654MiB /  4043MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1925      G   /usr/libexec/Xorg                             89MiB |
|    0      2108      G   /usr/bin/gnome-shell                          44MiB |
|    0      2486      G   /usr/libexec/Xorg                            776MiB |
|    0      2611      G   /usr/bin/gnome-shell                         323MiB |
|    0      2861      G   ...are/jetbrains-toolbox/jetbrains-toolbox   401MiB |
|    0      2876      G   cairo-dock                                    12MiB |
+-----------------------------------------------------------------------------+

#or you can use the following command

[email protected]:~>cat /proc/driver/nvidia/version 
NVRM version: NVIDIA UNIX x86_64 Kernel Module  418.43  Tue Feb 19 01:12:11 CST 2019
GCC version:  gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC) 

#third option to get the driver details

[email protected]:~>modinfo nv