MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / effective_driver_gpu_count

Function effective_driver_gpu_count

crates/openshell-core/src/gpu.rs:40–51  ·  view source on GitHub ↗

Return the effective compute-driver GPU count. A present GPU requirement with an omitted count requests one GPU. # Errors Returns an error when a GPU requirement explicitly requests zero GPUs.

(
    gpu: Option<&DriverGpuResourceRequirements>,
)

Source from the content-addressed store, hash-verified

38/// # Errors
39/// Returns an error when a GPU requirement explicitly requests zero GPUs.
40pub fn effective_driver_gpu_count(
41 gpu: Option<&DriverGpuResourceRequirements>,
42) -> Result<Option<u32>, String> {
43 let Some(gpu) = gpu else {
44 return Ok(None);
45 };
46 let count = gpu.count.unwrap_or(1);
47 if count == 0 {
48 return Err("gpu count must be greater than 0".to_string());
49 }
50 Ok(Some(count))
51}
52
53/// Return the requested compute-driver GPU requirements, if present.
54#[must_use]

Callers 7

validate_gpu_requestMethod · 0.85
validate_gpu_requestMethod · 0.85
validate_gpu_requestFunction · 0.85
validate_gpu_requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected