pub fn device_compute_capability_of(ordinal: usize) -> Result<(u32, u32)>Expand description
(major, minor) compute capability of GPU ordinal, with NO current
context required on the calling thread.
This exists because the context-addressed spelling above is wrong for a
preflight, and quietly so. cuda_host::host(ordinal) binds a context only
while it INITIALISES: once its OnceLock is populated it hands back an
Arc clone and touches no thread-current state. A TUI Library swap runs
the new load on a fresh atlas-swap thread while the previous model’s
context was made current on the scheduler thread, so on the swap thread
cuCtxGetDevice has no context to read and returns
CUDA_ERROR_INVALID_CONTEXT — failing the requested load AND the attempt
to restore the old model, leaving the host with no model at all.
cuDeviceGet reads no thread-current state (NVIDIA’s context API
documents the thread-current requirement as belonging to cuCtx*, not to
device enumeration), so the preflight needs no bind and cannot be made
wrong by which thread it runs on. cuInit is still a precondition, and the
host(ordinal) call in preflight_device_arch_with is what satisfies it.