dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
22.21k stars 1.67k forks source link

Feature request: read GPU name from udev #1646

Open ChALkeR opened 3 years ago

ChALkeR commented 3 years ago

Description

This is mainly about faster pci.ids updates (see below).

E.g.:

$ lspci | grep VGA
04:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 41)
1a:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] (rev c5)
af:00.0 VGA compatible controller: NVIDIA Corporation Device 2204 (rev a1)

This is what neofetch reports (note how Nvidia card is obscurely named).

Currently, neofetch reports them as:

GPU: NVIDIA af:00.0 NVIDIA Corporation Device 2204 
GPU: AMD ATI Radeon RX 5500/5500M / Pro 5500M 

But let's demonstrate how the (widely available) udevadm can be used to fetch more info (or actually, less outdated info, see below):

$ udevadm info -q property -p /sys/bus/pci/devices/0000:1a:00.0 | grep ID_MODEL_FROM_DATABASE
ID_MODEL_FROM_DATABASE=Navi 14 [Radeon RX 5500/5500M / Pro 5500M]
$ udevadm info -q property -p /sys/bus/pci/devices/0000:af:00.0 | grep ID_MODEL_FROM_DATABASE
ID_MODEL_FROM_DATABASE=GA102 [GeForce RTX 3090]

Paths are taken using the PCI slot names already known from lspci.

That is able to decode the NVidia GPU name (and likely others where just lspci is not sufficient).

Without udevadm

Alternatively:

$ cat /run/udev/data/+pci:0000:af:00.0 | grep ID_MODEL_FROM_DATABASE
E:ID_MODEL_FROM_DATABASE=GA102 [GeForce RTX 3090]

Provides the same info and is essentially what udevadm does. Not sure how exactly portable is that, though.

pci.ids

That combination is already present in upstream pci.ids, added on 2020-09-21, over three months ago. But hwids (which provides /usr/share/hwdata/pci.ids used by lspci) is updated less frequently than udev (actually, systemd), apparently.

For comparison:

Neofetch version

7.1.0

pciutils: 3.7.0 hwids: 20200813.1-1

xbjfk commented 3 years ago

I propose an additional solution (Maybe for AMD only?): Currently, both lspci and neofetch show my GPU as Radeon RX 5600 OEM/5600 XT / 5700/5700 XT, however glxinfo shows OpenGL renderer string: AMD Radeon RX 5700 XT (NAVI10, DRM 3.40.0, 5.11.8-gentoo-r1, LLVM 11.1.0)

With a grep the output can be cleaned up into:

glxinfo -B | grep -Po '(?<=^OpenGL renderer string: ).*(?= \(.*\)$)'
AMD Radeon RX 5700 XT
githubmo commented 3 years ago

udevadm nor any of the techniques above using cat worked for me. I have managed to get it to work using glxinfo -B | grep -Po '(?<=^OpenGL renderer string: ).* by modifying @xbjfk's version above to work with Nvidia GPUs.

Here is the commit from my local version https://github.com/githubmo/neofetch/commit/23b9eaf40c70667ad62e3593c75a39b04e165280 so you can clone and install my version if you wish to use that for Nvidia GPUs.

Since I don't have any AMD or older GPUs to test with, I will not be raising a PR for this.

P.S. the following is the output I get:

❯ glxinfo -B | grep -Po '(?<=^OpenGL renderer string: ).*'
GeForce RTX 3090/PCIe/SSE2
amzon-ex commented 2 years ago

Any update on official support of this enhancement?

andreiarg commented 1 year ago

I'd like to see this implemented as well. My RX 5700 XT gets reported strictly as "AMD ATI Radeon RX 5600 OEM/5600" in Ubuntu 22.0.4.3 even though glxinfo and Ubuntu settings will show it as the 5700 XT it is.