We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18cbecf commit 58934c8Copy full SHA for 58934c8
launcher/src/main.rs
@@ -1263,7 +1263,23 @@ fn num_cuda_devices() -> Option<usize> {
1263
let devices = match env::var("CUDA_VISIBLE_DEVICES") {
1264
Ok(devices) => devices,
1265
Err(_) => match env::var("NVIDIA_VISIBLE_DEVICES") {
1266
- Ok(devices) => devices,
+ Ok(devices) => {
1267
+ if devices.trim() == "all" {
1268
+ // Count the number of all GPUs via nvidia-smi
1269
+ let output = Command::new("nvidia-smi")
1270
+ .args(["--query-gpu=uuid", "--format=csv,noheader"])
1271
+ .output()
1272
+ .ok()?;
1273
+
1274
+ String::from_utf8_lossy(&output.stdout)
1275
+ .lines()
1276
+ .filter(|line| !line.trim().is_empty())
1277
+ .count()
1278
+ .to_string()
1279
+ } else {
1280
+ devices
1281
+ }
1282
1283
Err(_) => env::var("ZE_AFFINITY_MASK").ok()?,
1284
},
1285
};
0 commit comments