-
Notifications
You must be signed in to change notification settings - Fork 164
Detect AMD GPUs without lspci #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3e60e2b to
150d49a
Compare
150d49a to
4b6563a
Compare
|
@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. |
danielholanda
left a comment
There was a problem hiding this 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)"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| f"/sys/bus/pci/devices/{pci_id}/mem_info_vram_total", | ||
| "/sys/class/drm/card*/device/mem_info_vram_total", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
| # 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 |
There was a problem hiding this comment.
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
896c93e to
b8e2234
Compare
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]>
b8e2234 to
aa2eaf8
Compare
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.