sysfetch icon indicating copy to clipboard operation
sysfetch copied to clipboard

Finding GPU without lspci

Open IndrekHaav opened this issue 4 years ago • 8 comments

Debian 10 under WSL2, script throws an error when trying to find a GPU:

gpu ~ ./fetch.sh: line 67: lspci: command not found

Looks like pciutils might not be installed by default on Debian, at least when running without a desktop.

IndrekHaav avatar Nov 22 '21 09:11 IndrekHaav

Really trying to resolve this as soon as possible.. I look around and went through some alternative's code and noticed they used lspci as well. Finding a work around to stat gpu without another external dependency could be difficult. I'm working on statement to make output 2 gpu's if exist on new line like gpu1 ~ ... gpu2 ~ ...

wick3dr0se avatar Nov 24 '21 00:11 wick3dr0se

I also saw the same error in Debian 10 LXC containers running on Proxmox. It's possible both WSL and LXC are running slimmed-down OS images that lack some utils related to physical hardware. I don't have a full Debian system (physical or VM) at hand right now.

IndrekHaav avatar Nov 24 '21 19:11 IndrekHaav

@IndrekHaav I made a way to extract vendor and device id from /proc/bus/pci/devices, which we can use to get GPU info. I need to see output other than my own to see if some common fields exist. If you can share the output of cat /proc/bus/pci/devices; I can likely make this work

wick3dr0se avatar Dec 22 '21 17:12 wick3dr0se

If anyone can share their output of /proc/bus/pci/devices; I believe we will have the only alternative to lspci, with no dependency. Currently there is no other method to get GPU information on Linux. I think I found a way around that. The script I made in testing returns the value scraped from a PCI ID database. I need to find consistencies in /proc/bus/pci/devices to be able to utilize the correct vendor and device ID

wick3dr0se avatar Dec 24 '21 17:12 wick3dr0se

Debian 10 on WSL2:

~$ cat /proc/bus/pci/devices
0000    1414008e        0                      0                       0                       0                       0                       0                       0                       0                       0
   0                   0                       0                       0                       0                       0        dxgkrnl

IndrekHaav avatar Dec 25 '21 18:12 IndrekHaav

This isn't the right line from /proc/bus/pci/devices. It does contain your vendor ID but there is a specific line that contains the vendor and device ID in the 2nd field combines like 1414 is your vendor. The ending 4 should be your device ID. I found a consistency in mine and another's output. On the line that contains the vendor and device ID, I found that there was a number ending in 0000c on that line somewhere. I use that to print the line then grab field 2 from it.

This is the relevant line on my system:

0600	10026995	41	        d000000c	               0	        e000000c	               0	            e001	        fcf00000           c0002	        10000000	               0	          200000	               0	             100	           40000	           20000	amdgpu

From field 2, 1002 is the vendor ID and 6995 is the device ID, which I used to scrape the name of the GPU from this PCI ID database. Returning: Advanced Micro Devices, Inc. [AMD/ATI] Lexa XT [Radeon PRO WX 2100]

I just pushed a commit to testing with the changes I found. It's labeled gpu-nix, hopefully it will work for everyone

wick3dr0se avatar Dec 26 '21 17:12 wick3dr0se

That's all the output I got.

IndrekHaav avatar Dec 26 '21 17:12 IndrekHaav

That's odd.. What type of GPU do you have? I edited my comment above to give more perspective on how it works

wick3dr0se avatar Dec 26 '21 17:12 wick3dr0se