linux上查看gpu卡型_如何检查Linux上安装了哪个GPU

linux上查看gpu卡型

linux上查看gpu卡型

A Linux laptop with a terminal window open.
Fatmawati Achmad Zaenuri/Shutterstock Fatmawati Achmad Zaenuri / Shutterstock

Need to identify the Graphics Processing Unit (GPU) in a Linux computer? Here’s how you can identify the graphics card from the command line and in GNOME.

是否需要识别Linux计算机中的图形处理单元(GPU)? 这是从命令行和GNOME中识别图形卡的方法。

第一步 (The First Step)

You’ve probably been there. You’re drafted to provide support for a nontechie relative or work colleague, and something tells you this isn’t going to be painless. Still, you pitch in! You quickly determine the issue is likely a display driver issue. Hey, this might not be so bad after all! But then your short-lived flicker of hope is snuffed when you ask, “What kind of graphics card do you have?”

你可能去过那里。 您被征召为非技术人员的亲戚或工作同事提供支持,并且有些事情告诉您,这不会很轻松。 不过,您还是参与其中! 您Swift确定该问题很可能是显示驱动程序问题。 嘿,毕竟这可能还不错! 但是,当您问“您拥有哪种图形卡?”时,您短暂的希望闪烁就消失了。

The deer-in-headlights expression you receive in response speaks volumes. To support something, you need to know what it is. So how do you identify the graphics card in a Linux computer?

您在响应中收到的“大鹿的表情”可以说明一切。 要支持某件事,您需要知道它是什么。 那么,如何识别Linux计算机中的图形卡呢?

Let’s assume the worst-case scenario and say the drivers for the graphics card were never installed, so you can’t even look at those to get a clue. It doesn’t matter! You can solve this conundrum either from the command line or through the graphical user interface (GUI).

让我们假设最坏的情况,并说从未安装图形卡的驱动程序,因此您甚至无法查看这些驱动程序以获取线索。 没关系! 您可以从命令行或通过图形用户界面(GUI)解决此难题。

lspci和PCI ID数据库 (lspci and the PCI ID Database)

The Peripheral Component Interconnect (PCI) standard is a common protocol you can use to talk to internal peripherals, such as graphics cards. The PCI ID Repository maintains a database of all known IDs for PCI devices. This means if you know some information about the device, you can look it up.

外围组件互连(PCI)标准是一种常用协议,可用于与内部外围设备(例如图形卡)进行通信。 PCI ID存储库维护着PCI设备所有已知ID的数据库。 这意味着,如果您知道有关该设备的某些信息,则可以查找它。

You can use the lspci command to list the PCI devices installed on a Linux computer, as well as some information about them.

您可以使用lspci命令列出Linux计算机上安装PCI设备以及有关它们的一些信息。

Wouldn’t it be great if we could tie the PCI database and the lspci command together? Well, actually, that’s exactly what happens when you run the lspci command. It checks a local copy of the PCI database to identify the PCI devices it detects. Before we start, it’s wise to update the local copy of the PCI database.

如果我们可以将PCI数据库和lspci命令绑定在一起,那不是很好吗? 好吧,实际上,这就是运行lspci命令时发生的情况。 它检查PCI数据库的本地副本,以识别它检测到的PCI设备。 在开始之前,明智的做法是更新PCI数据库的本地副本。

Type the update-pciids command to do just that:

键入update-pciids命令即可

sudo update-pciids
The "sudo update-pciids" command in a terminal window.

The latest database version is retrieved for us, and we can now use the lspci command. There’ll be a lot of output, so we’ll pipe it into less. The -v (verbose) option tells lscpi to give us as much information as it can. We’ll use sudo to ensure the information is as detailed as possible.

已为我们检索了最新的数据库版本,现在我们可以使用lspci命令。 会有很多输出,因此我们将其输出到less-v (详细)选项告诉lscpi给我们尽可能多的信息。 我们将使用sudo来确保信息尽可能详细。

We type our command as follows:

我们输入以下命令:

sudo lspci -v | less
The "sudo lspci -v | less" command in a terminal window.

The results appear in less. If you press the forward-slash (/), you activate the less search function.

结果出现在less 。 如果按正斜杠( / ),则会激活less搜索功能。

Type “VGA” in all caps and press Enter.

在所有大写字母中键入“ VGA”,然后按Enter。

Type "VGA" in all caps in the terminal window.

less searches for the string, “VGA,” and it shows you the first matches it finds. From that point, you can scroll or page forward to see how many graphics cards lspci found.

less搜索字符串“ VGA”,它会向您显示找到的第一个匹配项。 从那时起,您可以滚动或向前翻页以查看lspci找到了多少张显卡。

Search results for "VGA" in the lspci output from the "less" command in a terminal window.

For this article, we conducted our research on a variety of Linux distributions running in VirtualBox virtual machines. Virtual machines, of course, have virtual graphics cards.

在本文中,我们对在VirtualBox虚拟机中运行的各种Linux发行版进行了研究。 虚拟机当然具有虚拟图形卡。

So you can see an example of real-world results, here’s the output from the host (physical) computer:

因此,您可以看到一个真实结果的示例,这是主机(物理)计算机的输出:

26:00.0 VGA compatible controller: NVIDIA Corporation GP108 [GeForce GT 1030] (rev a1) (prog-if 00 [VGA controller])
Subsystem: Gigabyte Technology Co., Ltd GP108 [GeForce GT 1030]
Flags: bus master, fast devsel, latency 0, IRQ 97
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 000c0000 [disabled] [size=128K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Legacy Endpoint, MSI 00
Capabilities: [100] Virtual Channel
Capabilities: [250] Latency Tolerance Reporting
Capabilities: [128] Power Budgeting <?>
Capabilities: [420] Advanced Error Reporting
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
Capabilities: [900] Secondary PCI Express <?>
Kernel driver in use: nouveau
Kernel modules: nouveau

It gave us a lot of good information right away!

它立即为我们提供了很多很好的信息!

The card is an NVIDIA Corporation GP108 [GeForce GT 1030], and, after a few seconds with a search engine, we found the NVIDIA tech page for that device. The “[VGA controller]” text at the end of the first line indicates this is the “operational” graphics card. That’s useful info when more than one card is installed on a computer.

该卡是NVIDIA Corporation GP108 [GeForce GT 1030],在使用搜索引擎几秒钟后,我们找到了该设备NVIDIA技术页面。 第一行末尾的“ [VGA控制器]”文本表示这是“可运行的”图形卡。 当计算机上安装多个卡时,这是有用的信息。

lshw命令 (The lshw Command)

You can also use the lshw command to list the hardware installed on a Linux computer. It reports a variety of types, too—not just PCI hardware.

您也可以使用lshw命令列出Linux计算机上安装的硬件。 它也报告多种类型,而不仅仅是PCI硬件。

To tell it to report on the graphics cards it finds, we’ll use the -C (class) option and pass the “display” modifier. The -numeric option forces lshw to provide the numeric IDs of the devices, as well as their names.

为了告诉它报告所找到的图形卡,我们将使用-C (类)选项并传递“ display”修饰符。 -numeric选项强制lshw提供设备的数字ID及其名称。

Type the following:

输入以下内容:

sudo lshw -numeric -C display
The "sudo lshw -numeric -C display" command in a terminal window.

Here’s what that command found on the physical computer:

这是在物理计算机上找到的命令:

 *-display 
   description: VGA compatible controller
   product: GP108 [GeForce GT 1030] [10DE:1D01]
   vendor: NVIDIA Corporation [10DE]
   physical id: 0
   bus info: pci@0000:26:00.0
   version: a1
   width: 64 bits
   clock: 33MHz
   capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
   configuration: driver=nouveau latency=0
   resources: irq:97 memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-f1ffffff ioport:e000(size=128) memory:c0000-dffff

Encouragingly, both found the same card!

令人鼓舞的是,他们俩都发现了同一张卡!

The [10DE:1D01] identifiers represent the manufacturer (10DE) and the model (1D01). To find the make and model immediately, you could type “graphics card 10de:1d01” into a search engine.

[10DE:1D01]标识符代表制造商(10DE)和型号(1D01)。 要立即查找品牌和型号,您可以在搜索引擎中输入“ graphics card 10de:1d01”。

glxinfo命令 (The glxinfo Command)

The glxinfo command is yet another method you can use. It gives you information from the OpenGL extension for the X Windows system. You can then search some of that information to find out what kind of graphics card is installed on a machine.

glxinfo命令是您可以使用的另一种方法。 它为X Windows系统提供了来自OpenGL扩展的信息。 然后,您可以搜索某些信息,以了解计算机上安装了哪种图形卡。

The glxinfo command is already present on Manjaro and Fedora, but you have to install it on Ubuntu. To do so, type the following command:

glxinfo命令已经存在于Manjaro和Fedora上,但是您必须在Ubuntu上安装它。 为此,请键入以下命令:

sudo apt-get install mesa-utils
The "sudo apt-get install mesa-utils" command in a terminal window.

To pipe the output from glxinfo through less, and use the -B (print IDs) option, type the following:

要通过less传递glxinfo的输出,并使用-B (打印ID)选项,请键入以下内容:

glxinfo -B | less
The "glxinfo -B | less" command in a terminal window.

The graphics card is described in the “Device” line.

图形卡在“设备”行中描述。

The Device line highlighted in the output from the "glxinfo -B | less" in a terminal window.

This is the output from the physical computer:

这是物理计算机的输出:

name of display: :1
display: :1 screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
Vendor: nouveau (0x10de)
Device: NV138 (0x1d01)
Version: 19.3.2
Accelerated: yes
Video memory: 1987MB
Unified memory: no
Preferred profile: core (0x1)
Max core profile version: 4.3
Max compat profile version: 4.3
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.2
OpenGL vendor string: nouveau
OpenGL renderer string: NV138
OpenGL core profile version string: 4.3 (Core Profile) Mesa 19.3.2
OpenGL core profile shading language version string: 4.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.3 (Compatibility Profile) Mesa 19.3.2
OpenGL shading language version string: 4.30
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 19.3.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

When you type “NV138” into a search engine, the NVIDIA graphics card is identified immediately.

在搜索引擎中键入“ NV138”时,将立即识别NVIDIA图形卡。

使用GUI识别图形卡 (Using the GUI to Identify the Graphics Card)

If the computer is a CLI-only server, you have to use one of the techniques we covered above. If it has a (working) GUI, though, there’s likely a graphical way you can identify the graphics card. In fact, that option is probably somewhere in your Linux desktop settings tools.

如果计算机是仅CLI的服务器,则必须使用我们上面介绍的技术之一。 但是,如果它具有(正常工作的)GUI,则可能会以图形方式识别图形卡。 实际上,该选项可能在Linux桌面设置工具中的某个位置。

On a GNOME desktop, open the “Settings” dialog, and then click “Details” in the sidebar. In the “About” panel, look for a “Graphics” entry. This tells you what kind of graphics card is in the computer, or, more specifically, the graphics card that’s currently in use. Your machine might have more than one GPU.

在GNOME桌面上,打开“设置”对话框,然后单击侧栏中的“详细信息”。 在“关于”面板中,查找“图形”条目。 这将告诉您计算机中使用的是哪种图形卡,或更具体地说,是当前正在使用的图形卡。 您的计算机可能具有多个GPU。

The GNOME Settings "About" tab on an Ubuntu virtual machine.

In the GNOME Settings “About” tab from a physical host, we get the same “NV138” card ID we saw earlier. Again, we can plug that info into a search engine to find the card type.

在物理主机的GNOME设置的“关于”选项卡中,我们获得了与之前看到的相同的“ NV138”卡ID。 同样,我们可以将该信息插入搜索引擎以查找卡类型。

The GNOME Settings "About" tab for a physical host.

笔记本电脑上的图形卡 (Graphics Cards on Laptops)

Many laptops have two graphics cards: one from the manufacturer of the central processing unit (CPU), and one from a mainstream GPU provider.

许多笔记本电脑都有两张图形卡:一张来自中央处理器(CPU)的制造商,另一张来自主流GPU提供商。

Let’s type the same lspci command from earlier, but this time, we’ll run it on a laptop:

让我们键入之前的相同的lspci命令,但是这次,我们将在笔记本电脑上运行它:

sudo lspci -v | less

As expected, we get a description of the graphics cards in the machine:

如预期的那样,我们获得了机器中图形卡的描述:

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. 3rd Gen Core processor Graphics Controller
Flags: bus master, fast devsel, latency 0, IRQ 33
Memory at f7400000 (64-bit, non-prefetchable) [size=4M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000 [size=64]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [a4] PCI Advanced Features
Kernel driver in use: i915
Kernel modules: i915

01:00.0 VGA compatible controller: NVIDIA Corporation GF119M [GeForce 610M] (rev a1) (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. GF119M [GeForce 610M]
Flags: bus master, fast devsel, latency 0, IRQ 34
Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
Memory at e0000000 (64-bit, prefetchable) [size=128M]
Memory at e8000000 (64-bit, prefetchable) [size=32M]
I/O ports at e000 [size=128]
Expansion ROM at f7000000 [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: nouveau
Kernel modules: nouveau

This laptop has both an Intel Core GPU and an NVIDIA GeForce 610M. However, both cards have the “[VGA controller]” string, which usually indicates which GPU is in use.

该笔记本电脑同时具有Intel Core GPU和NVIDIA GeForce 610M。 但是,两块卡都有“ [VGA controller]”字符串,该字符串通常指示正在使用哪个GPU。

They can’t both be in use, so try to get the card from the mainstream GPU provider working first. That’s the one the laptop manufacturer considers the default and includes in the hardware specifications for the machine.

它们不能同时使用,因此请首先让主流GPU提供商提供该卡。 这就是笔记本电脑制造商考虑的默认值,并包含在计算机的硬件规格中。

One of the techniques we’ve covered here is sure to work for you! After you know which type of graphics card a computer or laptop has, you can select the appropriate graphics driver.

我们在这里介绍的一种技术一定会为您服务! 在知道计算机或膝上型计算机具有哪种类型的图形卡之后,您可以选择适当的图形驱动程序。

翻译自: https://www.howtogeek.com/508993/how-to-check-which-gpu-is-installed-on-linux/

linux上查看gpu卡型

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值