(gpu_device: &str)
| 258 | } |
| 259 | |
| 260 | fn runtime_gpu_lines(gpu_device: &str) -> Vec<String> { |
| 261 | let engine = container_engine(); |
| 262 | let image = gpu_probe_image(); |
| 263 | let output = engine |
| 264 | .command() |
| 265 | .args([ |
| 266 | "run", |
| 267 | "--rm", |
| 268 | "--device", |
| 269 | gpu_device, |
| 270 | image.as_str(), |
| 271 | "nvidia-smi", |
| 272 | "-L", |
| 273 | ]) |
| 274 | .output() |
| 275 | .unwrap_or_else(|err| { |
| 276 | panic!( |
| 277 | "failed to run {} GPU probe container with image {image}: {err}", |
| 278 | engine.name() |
| 279 | ) |
| 280 | }); |
| 281 | |
| 282 | let stdout = String::from_utf8_lossy(&output.stdout); |
| 283 | let stderr = String::from_utf8_lossy(&output.stderr); |
| 284 | let combined = format!("{stdout}{stderr}"); |
| 285 | assert!( |
| 286 | output.status.success(), |
| 287 | "{} GPU probe failed for {gpu_device} with image {image} and status {:?}:\n{}", |
| 288 | engine.name(), |
| 289 | output.status.code(), |
| 290 | combined |
| 291 | ); |
| 292 | |
| 293 | let lines = gpu_lines(&stdout); |
| 294 | assert!( |
| 295 | !lines.is_empty(), |
| 296 | "{} GPU probe for {gpu_device} did not report any GPU lines with image {image}:\n{combined}", |
| 297 | engine.name() |
| 298 | ); |
| 299 | lines |
| 300 | } |
| 301 | |
| 302 | async fn sandbox_gpu_lines(gpu_device: Option<&str>) -> Vec<String> { |
| 303 | let mut args = vec!["--gpu"]; |
no test coverage detected