resource_stats
Live readings for the dashboards' gauges: GPU utilization and memory,
universal across vendors, the session's CPU and memory (SystemUsage), and
the one sampler both transports run over them (ResourceMonitor).
Sources, best-first: NVIDIA reads NVML in-process via nvidia-ml-py (the API
behind nvitop/nvtop; exact PCI identity, no subprocess per poll) with an
nvidia-smi fallback, and Tegra's integrated GPU, which has neither, reports
its load through devfreq. Every other card is read through DRM: amdgpu counts
utilization and VRAM device-wide in sysfs, and the rest have the engine times in
their clients' fdinfo summed, the kernel's vendor-neutral interface that i915,
xe, Mali, Adreno and VideoCore all write. A card whose driver writes neither --
Apple's, on Asahi -- is listed with no utilization rather than a zero.
get_gpus(dri_node=...) keys the readings to the render node the pipeline
captures/encodes on (PCI match when the source knows its address, else a
vendor-unique match), so the monitored GPU is always the one doing the work.
Objects expose .load as a 0..1 fraction, None where nothing on the host
counts the card's utilization, and .memoryTotal / .memoryUsed in MiB,
the units the stats collectors serialize.
attributelogger= logging.getLogger('stats')attributeCGROUP_ROOT= '/sys/fs/cgroup'attributePROC_CGROUP= '/proc/self/cgroup'