Skip to content

Commit 076ba79

Browse files
committed
Fix: try instead using cuda-sys' linux logic
1 parent f70517f commit 076ba79

File tree

1 file changed

+24
-8
lines changed
  • crates/find_cuda_helper/src

1 file changed

+24
-8
lines changed

crates/find_cuda_helper/src/lib.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,31 @@ pub fn find_cuda_lib_dirs() -> Vec<PathBuf> {
109109

110110
#[cfg(not(target_os = "windows"))]
111111
pub fn find_cuda_lib_dirs() -> Vec<PathBuf> {
112-
if let Some(root_path) = find_cuda_root() {
113-
vec![
114-
root_path.clone().join("lib64"),
115-
root_path.clone().join("lib"),
116-
root_path.join("lib").join("stubs"),
117-
]
118-
} else {
119-
vec![]
112+
let mut candidates = read_env();
113+
candidates.push(PathBuf::from("/opt/cuda"));
114+
candidates.push(PathBuf::from("/usr/local/cuda"));
115+
for e in glob::glob("/usr/local/cuda-*").unwrap() {
116+
if let Ok(path) = e {
117+
candidates.push(path)
118+
}
119+
}
120+
121+
let mut valid_paths = vec![];
122+
for base in &candidates {
123+
let lib = PathBuf::from(base).join("lib64");
124+
if lib.is_dir() {
125+
valid_paths.push(lib.clone());
126+
valid_paths.push(lib.join("stubs"));
127+
}
128+
let base = base.join("targets/x86_64-linux");
129+
let header = base.join("include/cuda.h");
130+
if header.is_file() {
131+
valid_paths.push(base.join("lib"));
132+
valid_paths.push(base.join("lib/stubs"));
133+
continue;
134+
}
120135
}
136+
valid_paths
121137
}
122138

123139
#[cfg(target_os = "windows")]

0 commit comments

Comments
 (0)