flodl-hw 0.8.0

Hardware detection for flodl: GPUs and host RAM, with no libtorch and no CUDA runtime
Documentation
  • Coverage
  • 87.76%
    43 out of 49 items documented0 out of 0 items with examples
  • Size
  • Source code size: 139.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • flodl-labs/flodl
    60 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fab2s

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 flodl_hw::detect_gpus() {
    println!("[{}] {} {} {} MiB", gpu.index, gpu.short_name(), gpu.arch_label(), gpu.total_memory_mb);
}

Why it is its own crate

Two consumers need the same answers and cannot share code any other way:

  • flodl needs GPU identity before libtorch is initialized. Once libtorch latches onto a device list, CUDA_VISIBLE_DEVICES is ignored, and on a heterogeneous rig the cluster launcher's spawned children inherit a corrupted CUDA context. See the "no CUDA before Trainer::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 on flodl.

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}]' \
  cargo test

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