Repository navigation
fix(studio): resolve UUID-form CUDA_VISIBLE_DEVICES to physical GPU indices - #8917
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
LlamaCppBackend parsed the visibility mask on its own and read a UUID mask as no mask, so an unpinned GGUF load picked from every host GPU and re-emitted a numeric CUDA_VISIBLE_DEVICES naming a card the parent had hidden. Fall back to the parent GPU spec, which now resolves full-GPU UUID masks.
_visible_devices_mask read a UUID CUDA_VISIBLE_DEVICES as no mask, so the unpinned GGUF pick still saw every host GPU. Reuse _resolve_visible_physical_ids.
gpu_query never caches a failed nvidia-smi read and the parent GPU spec is read on every poll and load, so a failing or hung nvidia-smi under a UUID mask cost 42 ms to 5 s per call (spoofed nvidia-smi; 4 us on main). Now ~6 us after the first read.
Key it on gpu_query's static generation, which invalidate_detection() bumps on eGPU hotplug or a driver reset, so a re-detected inventory is read at once.
_nvidia_inference_devices reparsed CUDA_VISIBLE_DEVICES with int() once the mask resolved, raising on UUID tokens and dropping the inventory.
…olver The torch-backend visibility spec reads HIP or ZE masks under ROCm or XPU torch, so a CUDA llama.cpp backend there could map the UUID mask to the wrong card.
|
Review record for #8917, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#476. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Summary
Fixes #8873. On a multi-GPU NVIDIA host, setting
CUDA_VISIBLE_DEVICESto GPU UUIDs (GPU-<uuid>,GPU-<uuid>) instead of indices made Studio treat the GPUs as unpinnable: the per-model GPUs picker never rendered and any explicitgpu_idsload was rejected with HTTP 400. Unpinned GGUF loads were also placed on cards the mask hid.Changes
nvidia.resolve_uuid_mask()maps a full-GPU UUID mask to physicalnvidia-smiindices in mask order, reusing the existing_uuid_visible_ordinal_mapmatcher and the cachedgpu_queryread. MIG entries, unknown or ambiguous UUIDs, mixed index/UUID masks and duplicates stay unresolved, exactly as before._get_parent_visible_gpu_spec()uses it on CUDA hosts whileCUDA_DEVICE_ORDERisPCI_BUS_ID(Studio's default), so a resolvable UUID mask behaves exactly like the equivalent numeric mask.FASTEST_FIRSTand ROCm keep the old path._resolve_visible_physical_ids,_visible_devices_mask) fall back to the same resolution, so an unpinned GGUF load stays inside the mask instead of picking from every host GPU.nvidia-smidoes not cost its timeout on every poll.Testing
Real GPUs (B200 host), Studio base vs head,
CUDA_VISIBLE_DEVICES=<uuid of GPU 5>,<uuid of GPU 2>, card verified withnvidia-smi --query-compute-apps:5,2gpu_ids=[5]gpu_ids=[2]nvidia-smimatrix, 342 cells (19 masks x 3CUDA_DEVICE_ORDERx working / failing / empty / missing / hungnvidia-smi, plus ROCm routing): 330 identical to main, 12 newly resolved and all match CUDA's own UUID semantics, 0 violations.studio/backend/tests/test_gpu_selection.pycovers resolution order, fail-closed cases, theFASTEST_FIRST/ ROCm gates, the llama.cpp paths and the cache; the new tests fail with the fix reverted.Before / after
Run settings with GPU Memory set to Manual on a two-GPU UUID mask: