pub(crate) fn parse_compute_capability(stdout: &str) -> Option<String>Expand description
Parses nvidia-smi --query-gpu=compute_cap stdout ("X.Y\n" or
"X.Y\nX.Y\n…" for multi-device queries without -i) into an
ORT-compatible smXY string.
Defensive against extra whitespace, trailing newlines, and accidental
multi-line output (only the first non-empty line is consumed). Returns
None when:
- the input is empty after trimming;
- the first line is not exactly two dot-separated digit components
(
"X.Y", allowing 1+ digits each so"12.0"parses to"sm120").
Pure: no I/O, no globals. The exhaustive correctness tests in the
sibling test module exercise every failure shape so the production
invariant (“strict X.Y only”) cannot drift.