Unverified Commit 219714c8 authored by Guanzhong Chen's avatar Guanzhong Chen Committed by GitHub

Show GPU subsystem name if possible. Fixes #1490 (#1648)

After this change, if a subsystem name exists for a GPU, we display that name instead of the device name. This should fix the issue mentioned in #1490. For example, a card that would be shown as: GPU: AMD ATI Radeon RX 470/480/570/570X/580/580X/590 before will now be shown as: GPU: AMD ATI Radeon RX 480 4GB This fallback logic is implemented in the `awk` command. Additionally, the PCI address is now stripped from the awk output because it never is desirable to print it. It is, however, still kept internally in `awk` to distinguish multiple cards of the same model.
parent 9b110813
...@@ -2449,9 +2449,17 @@ get_gpu() { ...@@ -2449,9 +2449,17 @@ get_gpu() {
case $os in case $os in
"Linux") "Linux")
# Read GPUs into array. # Read GPUs into array.
gpu_cmd="$(lspci -mm | awk -F '\"|\" \"|\\(' \ gpu_cmd="$(lspci -mm |
'/"Display|"3D|"VGA/ {a[$0] = $1 " " $3 " " $4} awk -F '\"|\" \"|\\(' \
END {for(i in a) {if(!seen[a[i]]++) print a[i]}}')" '/"Display|"3D|"VGA/ {
a[$0] = $1 " " $3 " " ($7 ~ /^$|^Device [[:xdigit:]]+$/ ? $4 : $7)
}
END { for (i in a) {
if (!seen[a[i]]++) {
sub("^[^ ]+ ", "", a[i]);
print a[i]
}
}}')"
IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd" IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd"
# Remove duplicate Intel Graphics outputs. # Remove duplicate Intel Graphics outputs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment