Skip to content

Commit 2460b54

Browse files
authored
Add cudarc::driver::sys::is_available() (#316)
1 parent acdb1a2 commit 2460b54

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/driver/sys/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ mod sys_12060;
5858
#[cfg(feature = "cuda-12060")]
5959
pub use sys_12060::*;
6060

61+
/// Check if the driver library is available on the system.
62+
pub fn is_available() -> bool {
63+
let lib_name = "cuda";
64+
let mut choices = crate::get_lib_name_candidates(lib_name);
65+
choices.extend(crate::get_lib_name_candidates("nvcuda"));
66+
choices.iter().any(|x| unsafe { Lib::new(x).is_ok() })
67+
}
68+
6169
pub unsafe fn lib() -> &'static Lib {
6270
static LIB: std::sync::OnceLock<Lib> = std::sync::OnceLock::new();
6371
LIB.get_or_init(|| {

0 commit comments

Comments
 (0)