Skip to content

Commit

Permalink
Add cudarc::driver::sys::is_available()
Browse files Browse the repository at this point in the history
  • Loading branch information
coreylowman committed Jan 20, 2025
1 parent acdb1a2 commit bbc6985
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/driver/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ mod sys_12060;
#[cfg(feature = "cuda-12060")]
pub use sys_12060::*;

/// Check if the driver library is available on the system.
pub fn is_available() -> bool {
let lib_name = "cuda";
let mut choices = crate::get_lib_name_candidates(lib_name);
choices.extend(crate::get_lib_name_candidates("nvcuda"));
choices.iter().any(|x| unsafe { Lib::new(x).is_ok() })
}

pub unsafe fn lib() -> &'static Lib {
static LIB: std::sync::OnceLock<Lib> = std::sync::OnceLock::new();
LIB.get_or_init(|| {
Expand Down

0 comments on commit bbc6985

Please sign in to comment.