flodl-hw
Hardware detection for flodl: GPUs and host RAM,
with no libtorch and no CUDA runtime. One dependency, serde_json,
used only to read the test-spoofing env var below.
for gpu in detect_gpus
Why it is its own crate
Two consumers need the same answers and cannot share code any other way:
flodlneeds GPU identity before libtorch is initialized. Once libtorch latches onto a device list,CUDA_VISIBLE_DEVICESis ignored, and on a heterogeneous rig the cluster launcher's spawned children inherit a corrupted CUDA context. See the "no CUDA beforeTrainer::run" invariant.fdl(flodl-cli) needs the same answers before libtorch exists at all, to pick which libtorch variant to download or build. It therefore cannot depend onflodl.
The two used to carry hand-synchronized copies of the same struct and the same parser. This crate is the single source, and the place a second GPU vendor gets added exactly once.
Two enumerations, deliberately
| Function | Answers |
|---|---|
detect_gpus() |
what the runtime will see, visibility masks applied |
detect_gpus_physical() |
what is installed, masks ignored |
Provisioning decisions (which libtorch variant covers this box) want the physical set. Runtime decisions (does DDP auto-promote) want the visible set. Conflating them is a real bug in both directions, so they are named apart rather than distinguished by a boolean.
Never initializes a GPU runtime. An absent nvidia-smi is "no GPUs",
not an error.
Spoofing hardware
FLODL_TESTING_GPU_JSON replaces the whole sweep, so detection and
downstream routing can be tested on a machine without the hardware:
FLODL_TESTING_GPU_JSON='[{"vendor":"amd","arch":"gfx1030","vram_mb":16384}]' \
Visibility masks still apply on top. A malformed value panics rather than falling back to real hardware, so a typo cannot silently make a test report on the wrong machine.
License
MIT