From 839f993ed7d3c9dfeefd53105cb72dd7e6f7db69 Mon Sep 17 00:00:00 2001 From: maxtremblay Date: Wed, 15 Jan 2025 11:31:13 -0500 Subject: [PATCH] fix some path issues --- crates/cubecl-cuda/src/compute/server.rs | 14 ++++++++++---- xtask/src/commands/profile.rs | 9 +++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/cubecl-cuda/src/compute/server.rs b/crates/cubecl-cuda/src/compute/server.rs index 06f2a8162..4dedfefa4 100644 --- a/crates/cubecl-cuda/src/compute/server.rs +++ b/crates/cubecl-cuda/src/compute/server.rs @@ -470,10 +470,16 @@ fn cuda_path() -> Option { #[cfg(target_os = "linux")] { // If it is installed as part of the distribution - if std::fs::metadata("/usr/bin/nvcc").is_ok() { - return Some(PathBuf::from("/usr")); - } - return Some(PathBuf::from("/usr/local/cuda")); + return if std::fs::exists("/usr/local/cuda").is_ok_and(|exists| exists) { + Some(PathBuf::from("/usr/local/cuda")) + } else if std::fs::exists("/opt/cuda").is_ok_and(|exists| exists) { + Some(PathBuf::from("/opt/cuda")) + } else if std::fs::exists("/usr/bin/nvcc").is_ok_and(|exists| exists) { + // Maybe the compiler was installed within the user path. + Some(PathBuf::from("/usr")) + } else { + None + }; } #[cfg(target_os = "windows")] diff --git a/xtask/src/commands/profile.rs b/xtask/src/commands/profile.rs index 1263e8450..acd7cd0b4 100644 --- a/xtask/src/commands/profile.rs +++ b/xtask/src/commands/profile.rs @@ -78,12 +78,17 @@ impl Profile { let bins = get_benches(&options.bench); let bin = bins.first().unwrap().as_path().to_str().unwrap(); let file = format!("target/{}", options.bench); - + let ncu_bin_path = std::process::Command::new("which") + .arg(&options.ncu_path) + .output() + .map_err(|_| ()) + .and_then(|output| String::from_utf8(output.stdout).map_err(|_| ())) + .expect("Can't find ncu. Verified that it is installed."); run_process( "sudo", &[ "BENCH_NUM_SAMPLES=1", - &options.ncu_path, + ncu_bin_path.trim(), "--nvtx", "--set=full", "--call-stack",