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

Function enumerate_gpu_device_nodes

crates/openshell-sandbox/src/lib.rs:751–766  ·  view source on GitHub ↗

Enumerate per-GPU device nodes (`/dev/nvidia0`, `/dev/nvidia1`, …).

()

Source from the content-addressed store, hash-verified

749
750/// Enumerate per-GPU device nodes (`/dev/nvidia0`, `/dev/nvidia1`, …).
751fn enumerate_gpu_device_nodes() -> Vec<String> {
752 let mut paths = Vec::new();
753 if let Ok(entries) = std::fs::read_dir("/dev") {
754 for entry in entries.flatten() {
755 let name = entry.file_name();
756 let name = name.to_string_lossy();
757 if let Some(suffix) = name.strip_prefix("nvidia") {
758 if suffix.is_empty() || !suffix.chars().all(|c| c.is_ascii_digit()) {
759 continue;
760 }
761 paths.push(entry.path().to_string_lossy().into_owned());
762 }
763 }
764 }
765 paths
766}
767
768fn push_unique(paths: &mut Vec<String>, path: String) {
769 if !paths.iter().any(|p| p == &path) {

Calls 3

pushMethod · 0.80
pathMethod · 0.80
is_emptyMethod · 0.45