Pull requests / #1224

#1224 serve: the Monitor's AMD GPU readings on Windows through ADLX (load, VRAM, temperature, power)

open · @tuandat3019 · 0 评论 · 在 GitHub 查看

Setup & installServer & APIAMD / HIPWindowsLinux

描述

The Monitor tab (`/metrics`, `serve/telemetry.py`) reads NVIDIA through NVML and AMD on Linux through the
amdgpu sysfs files (#301).  On Windows an AMD card read nothing - the load, VRAM, temperature and power
places stayed blank.

Reading them there needs ADLX, AMD's current library: the old ADL Overdrive calls answer *not supported* on
current Adrenalin (measured on 32.0.21045: `ADL2_Overdrive6_Temperature_Get` rc=-9 for every one of the 13
adapter entries of the two cards, `ADL2_Overdrive6_CurrentPower_Get` answers 0 W), and the raw ADLX entry
points are not something a ctypes reader can hold - the 1.4 runtime's vtables close over internal objects and
the public headers' layout alone does not survive calling them (the calls fault).  AMD's supported client is
the ADLXPybind wheel, so this reads through it **as an optional import, in the same style as psutil**: without
the wheel the AMD cards keep reading nothing, exactly as before.

With the wheel present it reports load, VRAM used/total, edge temperature and board power (from the same
`IADLXGPUMetrics` object the fan, hotspot, clocks and shared memory are available; the Monitor's per-card
table uses the four above).  `free_vram_mib()` - the server's admission check - answers for these cards too.

Two details it gets right on Windows:

- **Card numbering**: the cards are ordered by PCI bus, ascending - the order HIP numbers them on Windows,
  which is what the engine's GPU numbering, `gpu_indices` and the Monitor's `gpu_index` refer to.  (Verified
  against the engine's own "GPU 1: AMD Radeon RX 6800" line on a two-card PC: RX 6600 bus 3 = HIP 0, RX 6800
  bus 6 = HIP 1.)  The ADLX GPU is matched to that walk by name - the ADLX list's own order is the reverse
  there - so a card the walk cannot name reports nothing rather than another card's numbers.
- **Present devices only**: the adapter list is walked with SetupAPI's `DIGCF_PRESENT`; the registry's
  `Enum\PCI` also holds ghost instances of a re-seated card (the same name, a stale bus) and they must not
  enter the numbering.

**Not included: the PCIe link.**  Windows' user-mode properties for it (`DEVPKEY_PciDevice_Current/Max`
`LinkSpeed`/`LinkWidth`) report the slot rather than the negotiated link - on this PC an x8 card reads x16,
against its own measured 13.6 GB/s host-to-device probe - and nothing else user-mode carries the link width
(the driver's registry keys, the GPU performance counters and ADLX all lack it).  The Monitor's PCIe places
therefore stay empty for these cards, as they have been.

Verified live on that PC (ADLXPybind 1.4.6, RX 6800 + RX 6600): RX 6800 63 C / 178 W / 99 % / VRAM 16.0 of
16.4 GB while serving; RX 6600 53 C / 17 W; with the wheel uninstalled the readers report nothing and the
rest of the Monitor is unchanged.

Install: `pip install adlxpybind` (wheels for cp310-cp312, win_amd64).

站内延伸阅读

链到安装、模型与版本说明,便于 SEO/GEO,非官方 issue 正文。