Enumerate per-GPU device nodes (`/dev/nvidia0`, `/dev/nvidia1`, …).
()
| 749 | |
| 750 | /// Enumerate per-GPU device nodes (`/dev/nvidia0`, `/dev/nvidia1`, …). |
| 751 | fn 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 | |
| 768 | fn push_unique(paths: &mut Vec<String>, path: String) { |
| 769 | if !paths.iter().any(|p| p == &path) { |