Skip to content

Commit 85ca409

Browse files
authored
Merge pull request #586 from PrimeIntellect-ai/fix/remove-hardcoded-nvml-path
fix(worker): use dynamic nvml lib init instead of hardcoding path
2 parents e57aa1d + ffb43ff commit 85ca409

File tree

1 file changed

+23
-10
lines changed
  • crates/worker/src/checks/hardware

1 file changed

+23
-10
lines changed

crates/worker/src/checks/hardware/gpu.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,31 @@ fn get_gpu_status() -> Vec<GpuDevice> {
4747

4848
// Initialize NVML if not already initialized
4949
if nvml_guard.is_none() {
50-
match Nvml::builder()
51-
.lib_path(std::ffi::OsStr::new(
52-
"/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1",
53-
))
54-
.init()
55-
{
56-
Ok(nvml) => *nvml_guard = Some(nvml),
57-
Err(e) => {
58-
Console::user_error(&format!("Failed to initialize NVML: {e}"));
59-
return vec![];
50+
// Try to load the NVIDIA management library dynamically
51+
let lib_paths = [
52+
"libnvidia-ml.so.1", // Standard Linux path
53+
"/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1", // Explicit path as fallback
54+
"/usr/lib/libnvidia-ml.so.1", // CUDA installation path
55+
];
56+
57+
let mut success = false;
58+
for path in lib_paths {
59+
match Nvml::builder().lib_path(std::ffi::OsStr::new(path)).init() {
60+
Ok(nvml) => {
61+
*nvml_guard = Some(nvml);
62+
success = true;
63+
break;
64+
}
65+
Err(_) => continue,
6066
}
6167
}
68+
69+
if !success {
70+
Console::user_error(
71+
"Failed to initialize NVML: could not load NVIDIA management library (libnvidia-ml.so.1)",
72+
);
73+
return vec![];
74+
}
6275
}
6376

6477
let nvml = nvml_guard.as_ref().unwrap();

0 commit comments

Comments
 (0)