服务器查看GPU等信息

lspci,顾名思义,就是显示所有的pci设备信息。pci是一种总线,而通过pci总线连接的设备就是pci设备了。如今,我们常用的设备很多都是采用pci总线了,如:网卡、存储。

如果没有lspci命令,安装:

1
apt-get install pciutils

查看gpu:

1
lspci  | grep -i vga

这样就可以显示机器上的显卡信息,比如

1
2
3
4
[root@localhost conf]# lspci | grep -i vga
01:00.0 VGA compatible controller: nVidia Corporation Device 1081 (rev a1)
02:00.0 VGA compatible controller: nVidia Corporation GT215 [GeForce GT 240] (rev a2)
08:05.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
如果想看详细的信息,比如 GeForce GT 240,即 02:00.0

[root@localhost conf]# lspci -v -s 02:00.0
02:00.0 VGA compatible controller: nVidia Corporation GT215 [GeForce GT 240] (rev a2) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Device 8351
Flags: bus master, fast devsel, latency 0, IRQ 169
Memory at f9000000 (32-bit, non-prefetchable) [size=16M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
Memory at ce000000 (64-bit, prefetchable) [size=32M]
I/O ports at bc00 [size=128]
[virtual] Expansion ROM at f8f80000 [disabled] [size=512K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Endpoint, MSI 00
Capabilities: [b4] Vendor Specific Information: Len=14 <?>
Capabilities: [100] Virtual Channel
Capabilities: [128] Power Budgeting <?>
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nvidia

可以看到GT240的显存是 256M

如果没有安装显卡驱动,显示可能如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@0765afb5370d:/# lspci  | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation Device 3e92
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c82 (rev a1)
root@0765afb5370d:/# lspci | grep -i 01:00.0
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c82 (rev a1)
root@0765afb5370d:/# lspci -v -s 01:00.0
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c82 (rev a1) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Device 8609
Flags: bus master, fast devsel, latency 0, IRQ 125
Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
Memory at e0000000 (64-bit, prefetchable) [size=256M]
Memory at f0000000 (64-bit, prefetchable) [size=32M]
I/O ports at e000 [size=128]
Expansion ROM at f7000000 [disabled] [size=512K]
Capabilities: <access denied>
Kernel driver in use: nouveau
lspci: Unable to load libkmod resources: error -12

查看nvidia的gpu信息

1
nvidia-smi

配合watch命令, 让一秒刷新一次

1
watch -n 1 nvidia-smi

查看内存及cpu使用情况的命令

1
top

htop工具,更直观

1
apt-get install htop

安装完后,直接输入命令

1
htop

就可以看到内存或cpu的使用情况了。

-------------本文结束 感谢您的阅读-------------