-
Notifications
You must be signed in to change notification settings - Fork 13
Fix AMD APU VRAM detection and formatting issues in amd.py #9
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?
Changes from all commits
70e060f
829e446
8933257
350061e
a5b16bd
dee9a2f
8db3232
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,17 @@ def detect(self) -> Devices | None: | |
| dev_gpu_vram_usage = pyamdsmi.amdsmi_get_gpu_vram_usage(dev) | ||
| dev_mem = dev_gpu_vram_usage.get("vram_total") | ||
| dev_mem_used = dev_gpu_vram_usage.get("vram_used") | ||
| # On APUs with unified memory (e.g., AMD Strix Halo), VRAM | ||
| # reports only the BIOS carveout (~512 MiB); VIS_VRAM reports | ||
| # the full usable system memory. Use VIS_VRAM when larger. | ||
| with contextlib.suppress(pyrocmsmi.ROCMSMIError): | ||
| dev_mem_vis_vram = byte_to_mebibyte( | ||
| pyrocmsmi.rsmi_dev_memory_total_get( | ||
| dev_idx, | ||
| pyrocmsmi.RSMI_MEM_TYPE_VIS_VRAM, | ||
| ), | ||
| ) | ||
| dev_mem = max(dev_mem, dev_mem_vis_vram) | ||
|
Comment on lines
+188
to
+192
|
||
| dev_ecc_count = pyamdsmi.amdsmi_get_gpu_ecc_count( | ||
| dev, | ||
| pyamdsmi.AmdSmiGpuBlock.UMC, | ||
|
|
@@ -189,6 +200,17 @@ def detect(self) -> Devices | None: | |
| dev_mem = byte_to_mebibyte( # byte to MiB | ||
| pyrocmsmi.rsmi_dev_memory_total_get(dev_idx), | ||
| ) | ||
| # On APUs with unified memory (e.g., AMD Strix Halo), VRAM | ||
| # reports only the BIOS carveout (~512 MiB); VIS_VRAM reports | ||
| # the full usable system memory. Use VIS_VRAM when larger. | ||
| with contextlib.suppress(pyrocmsmi.ROCMSMIError): | ||
| dev_mem_vis_vram = byte_to_mebibyte( | ||
|
Comment on lines
+203
to
+207
|
||
| pyrocmsmi.rsmi_dev_memory_total_get( | ||
| dev_idx, | ||
| pyrocmsmi.RSMI_MEM_TYPE_VIS_VRAM, | ||
| ), | ||
| ) | ||
| dev_mem = max(dev_mem, dev_mem_vis_vram) | ||
| dev_mem_used = byte_to_mebibyte( # byte to MiB | ||
| pyrocmsmi.rsmi_dev_memory_usage_get(dev_idx), | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,11 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ROCMSMI_IOLINK_TYPE_XGMI = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ROCMSMI_IOLINK_TYPE_NUMIOLINKTYPES = 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Memory Types ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RSMI_MEM_TYPE_VRAM = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RSMI_MEM_TYPE_GTT = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RSMI_MEM_TYPE_VIS_VRAM = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+67
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values for
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+65
to
+69
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Memory Types ## | |
| RSMI_MEM_TYPE_VRAM = 0 | |
| RSMI_MEM_TYPE_GTT = 1 | |
| RSMI_MEM_TYPE_VIS_VRAM = 2 | |
| ## Memory Types ## | |
| # Fallback numeric values that work even when rsmiBindings cannot be imported. | |
| RSMI_MEM_TYPE_VRAM = 0 | |
| RSMI_MEM_TYPE_GTT = 1 | |
| RSMI_MEM_TYPE_VIS_VRAM = 2 | |
| # If rsmi_memory_type_t is available from rsmiBindings, prefer the values | |
| # defined there so we stay in sync with the underlying library. | |
| if "rsmi_memory_type_t" in globals(): | |
| try: | |
| RSMI_MEM_TYPE_VRAM = int(rsmi_memory_type_t.RSMI_MEM_TYPE_VRAM) | |
| RSMI_MEM_TYPE_GTT = int(rsmi_memory_type_t.RSMI_MEM_TYPE_GTT) | |
| RSMI_MEM_TYPE_VIS_VRAM = int(rsmi_memory_type_t.RSMI_MEM_TYPE_VIS_VRAM) | |
| except Exception: | |
| # If anything unexpected happens, keep using the numeric fallbacks above. | |
| pass | |
| else: | |
| # When rsmiBindings is not importable, provide a minimal stand-in so that | |
| # references like rsmi_memory_type_t.RSMI_MEM_TYPE_VRAM used in default | |
| # arguments do not raise NameError at import time. | |
| class rsmi_memory_type_t: # type: ignore[override] | |
| RSMI_MEM_TYPE_VRAM = RSMI_MEM_TYPE_VRAM | |
| RSMI_MEM_TYPE_GTT = RSMI_MEM_TYPE_GTT | |
| RSMI_MEM_TYPE_VIS_VRAM = RSMI_MEM_TYPE_VIS_VRAM |
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.
The VIS_VRAM selection logic (comment + suppress block + max) is duplicated in both the
pyamdsmiand fallback branches. Consider extracting it into a small helper (or applying it once after the try/except) to avoid divergence if this logic needs future changes.