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

Function validate_gpu_request

crates/openshell-driver-vm/src/driver.rs:3172–3197  ·  view source on GitHub ↗
(sandbox: &Sandbox, gpu_enabled: bool)

Source from the content-addressed store, hash-verified

3170
3171#[allow(clippy::result_large_err)]
3172fn validate_gpu_request(sandbox: &Sandbox, gpu_enabled: bool) -> Result<(), Status> {
3173 let spec = sandbox
3174 .spec
3175 .as_ref()
3176 .ok_or_else(|| Status::invalid_argument("sandbox spec is required"))?;
3177
3178 let gpu_requirements = driver_gpu_requirements(spec.resource_requirements.as_ref());
3179 let gpu_count =
3180 effective_driver_gpu_count(gpu_requirements).map_err(Status::invalid_argument)?;
3181
3182 if gpu_requirements.is_some() && !gpu_enabled {
3183 return Err(Status::failed_precondition(
3184 "GPU support is not enabled on this driver; start with --gpu",
3185 ));
3186 }
3187
3188 let _ = vm_gpu_device_id(sandbox)?;
3189
3190 if gpu_count.is_some_and(|count| count > 1) {
3191 return Err(Status::invalid_argument(
3192 "VM GPU sandboxes support only one GPU",
3193 ));
3194 }
3195
3196 Ok(())
3197}
3198
3199#[allow(clippy::result_large_err)]
3200fn vm_gpu_device_id(sandbox: &Sandbox) -> Result<Option<String>, Status> {

Calls 3

driver_gpu_requirementsFunction · 0.85
vm_gpu_device_idFunction · 0.85