Pull requests / #1871

#1871 Dashboard: GPU load, VRAM, temperature, power and PCIe for AMD cards …

open · @WeisTekEng · 0 comentarios · En GitHub

Setup & installServer & APIAMD / HIPWindowsLinux

Descripción

## Title
Dashboard: GPU load, VRAM, temperature, power and PCIe for AMD cards on Windows

Issue: Resolves #1380 <!-- check this is the right issue: it is the one telemetry.py's own comment names for "no GPU load or VRAM readings for AMD cards on Windows". Use "Refs #1380" if it asks for more than this -->

## Summary
On Windows with an AMD card the Monitor dashboard showed nothing for GPU load, VRAM, temperature, power or PCIe, because `serve/telemetry.py` could only read the amdgpu sysfs files, which exist only on Linux. This adds a Windows reader that gets the same readings from DXGI, the performance counters, AMD's ADL library and the PCI device properties. Each source is optional: whatever fails to start leaves its readings empty and the others still show.

Tested on an RX 9070 XT Nitro+ (gfx1201), Windows, Ryzen 9 5900X. `python -m serve.telemetry 0 amd` on that PC:
```
GPU 0: AMD Radeon RX 9070 XT
sources: {'pdh': True, 'adl': True, 'pci': True}
ADL supported sensors (id: value): {1: 261, 2: 2786, 8: 25, 9: 28, 14: 3656, 15: 100, 19: 0, 20: 0, 21: 794, 27: 27, 38: 0, 39: 0, 40: 3, 41: 16, 46: 0, 47: 0, 48: 0, 49: 0, 58: 4, 73: 49}
{'util': 7.0, 'mem_used': 15658614784.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 54.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 7.0, 'mem_used': 15660449792.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 52.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 2.0, 'mem_used': 15660449792.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 45.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 3.0, 'mem_used': 15657566208.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 45.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 5.0, 'mem_used': 15647342592.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 46.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 5.0, 'mem_used': 15657566208.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 47.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 4.0, 'mem_used': 15657566208.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 44.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
{'util': 5.0, 'mem_used': 15657566208.0, 'mem_total': 16977723392, 'temp': 25.0, 'power': 45.0, 'pcie_gen': 5, 'pcie_gen_max': 5, 'pcie_width': 16}
```
<img width="1207" height="1115" alt="image" src="https://github.com/user-attachments/assets/6f17a6c0-449e-459b-bcf8-f6c47da934d8" />

## What changed
- `serve/telemetry.py`
  - New `_AmdWin` reader, chosen by `gpu_reader()` for the AMD backend on Windows. Linux and NVIDIA paths are unchanged.
  - DXGI: the card's name, device id, LUID and total VRAM. Adapters are ordered like HIP numbers them (an integrated Radeon first, then discrete cards), so `--gpu` selects the same card.
  - Performance counters (`GPU Engine`, `GPU Adapter Memory`) matched by the card's LUID: load (the busiest engine, as Task Manager shows) and VRAM in use. The query is reopened every 15 reads, and the last good value is kept for up to 3 empty reads.
  - ADL (`atiadlxx.dll`, installed with the Adrenalin driver), PMLog sensors: temperature, power and load. ADL reports AMD's vendor id as the decimal 1002, not 0x1002, so both are accepted.
  - SetupAPI PCI link properties: current and maximum PCIe generation, and width.
  - A source that does not start records why (`errors`), and `python -m serve.telemetry [index] [amd]` prints it with eight seconds of readings, so a problem on someone's PC can be diagnosed without starting the server.
  - The `gpu_note` text no longer says "Windows" or "Linux" and names what was tried.
- `serve/web/app.js`: the VRAM tile's fallback text is now "not available" instead of "not available on Windows AMD yet".
- `serve/test_telemetry_amd_windows.py` (new, 17 tests): parsing, sensor choice, adapter ordering, ctypes struct sizes, and the fallbacks, with the Windows APIs faked so they run anywhere.
- `serve/test_server.py`: `AmdTelemetry` is pinned to the Linux reader (`@mock.patch("serve.telemetry.IS_WIN", False)`). Those tests fake a sysfs tree and call `gpu_reader(…, amd=True)`, so on a Windows machine they were getting the new reader and failing.

## Extra Notes
- No new dependencies: everything is ctypes against DLLs Windows or the AMD driver already provide. No admin rights needed.
- PCIe throughput can't be read on Windows, so that tile shows the link (for example Gen5 x16) but no MB/s. The Windows reader also doesn't fill the `pcie_path` / `pcie_own_gen` keys from #1733, which are specific to the Linux sysfs walk.
- Two behaviours change on Windows AMD because they read the same values: `gpu_busy` (which uses the load reading) can now see a busy GPU, and `free_vram_mib` now returns a value instead of None. As far as I can tell both are only used when configured or by the watchdog, but please double-check.
- Only tested on one machine. Not tested: other Radeon cards, a PC with an integrated GPU plus a discrete one (the ordering follows #325 but is unverified), or two identical cards (ADL is matched by PCI device id, so it could pick the wrong one).
- ADL's units (temperature in °C, power in W) come from AMD's sensor definitions and match what the probe printed here. [Confirm this against your probe output before keeping this line.]
- Needs the Adrenalin driver for ADL. Without it, load, VRAM and PCIe still show.

En el sitio

Enlaces a install, modelos, releases.