Skip to content

Conversation

@superm1
Copy link

@superm1 superm1 commented Sep 26, 2025

shelling out to lspci and relying upon pciids.txt is fragile, especially when trying to run on an old distro. To avoid risk with this instead parse kfd sysfs files to determine if an APU or dGPU and build the graphics architecture.

@superm1 superm1 force-pushed the superm1/hw-ip-version branch from 3e60e2b to 150d49a Compare September 26, 2025 04:40
@superm1 superm1 marked this pull request as draft December 5, 2025 16:14
@superm1 superm1 force-pushed the superm1/hw-ip-version branch from 150d49a to 4b6563a Compare December 7, 2025 03:45
@superm1 superm1 marked this pull request as ready for review December 7, 2025 03:45
@superm1
Copy link
Author

superm1 commented Dec 7, 2025

@danielholanda OK - I've come up with a much more flexible approach. I parse the ISA from KFD. This should mean zero hardcoding for Linux in the future.

Copy link
Contributor

@danielholanda danielholanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some initial comments

GPUInfo gpu;
gpu.available = false;
gpu.error = "Failed to execute lspci command";
gpu.error = "No KFD nodes found (AMD GPU driver not loaded or no GPU present)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the guidance for the user in this scenario? Download the latest driver from Adrenalin?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most users should never see this. If you don't have a GPU driver you're probably going to have a pretty bad experience 😛

Here's a few reasons it might come up:

  • Brand new hardware, missing driver. This case means they need to update their kernel (or their distro)
  • Manually blocked amdgpu from loading. This case they need to unblock it.
  • Older hardware, older distro. Update hardware.

Comment on lines -1267 to -1268
f"/sys/bus/pci/devices/{pci_id}/mem_info_vram_total",
"/sys/class/drm/card*/device/mem_info_vram_total",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this ever fail due to permission issues?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! Permissions are openly readable for all users for this file.

❯ ls -alh /sys/class/drm/card0/device/mem_info_vram_total
-r--r--r-- 1 root root 4.0K Dec  8 16:02 /sys/class/drm/card0/device/mem_info_vram_total

Comment on lines -1236 to -1249
# Parse CSV output to extract VRAM
lines = output.split("\n")
for line in lines:
if "Total VRAM" in line or "vram" in line.lower():
# Extract numeric value (assuming it's in MB or GB)
numbers = re.findall(r"\d+", line)
if numbers:
vram_value = int(numbers[0])
# Assume MB if value is large, GB if small
if vram_value > 100: # Likely MB
vram_gb = round(vram_value / 1024, 1)
else: # Likely GB
vram_gb = float(vram_value)
return vram_gb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramkrishna2910 Would be great if you could take a look here

@superm1 superm1 force-pushed the superm1/hw-ip-version branch 3 times, most recently from 896c93e to b8e2234 Compare December 10, 2025 02:23
shelling out to lspci and relying upon pciids.txt is fragile,
especially when trying to run on an old distro.  To avoid risk with
this instead parse kfd sysfs files to determine if an APU or dGPU
and build the graphics architecture.

Signed-off-by: Mario Limonciello (AMD) <[email protected]>
@superm1 superm1 force-pushed the superm1/hw-ip-version branch from b8e2234 to aa2eaf8 Compare December 10, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants