Skip to content

Commit 11198ed

Browse files
committed
fix(cudart-sys): strip the "V" from the version string
1 parent 5727c7c commit 11198ed

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/cudart-sys/src/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::fs::File;
21
use std::path::{Path, PathBuf};
32

43
pub fn get_cuda_path() -> Option<&'static Path> {
@@ -47,18 +46,19 @@ pub fn get_cuda_lib_path() -> Option<PathBuf> {
4746
pub fn get_cuda_version() -> Option<String> {
4847
if let Some(version) = option_env!("CUDA_VERSION") {
4948
Some(version.to_string())
50-
} else if let Some(path) = get_cuda_path() {
49+
} else if get_cuda_path().is_some() {
5150
let re = regex_lite::Regex::new(r"V(?<version>\d{2}\.\d+\.\d+)").unwrap();
5251
let nvcc_out = std::process::Command::new("nvcc")
5352
.arg("--version")
5453
.output()
5554
.expect("failed to start `nvcc`");
5655
let nvcc_str = std::str::from_utf8(&nvcc_out.stdout).expect("`nvcc` output is not UTF8");
57-
let captures = re.captures(&nvcc_str).unwrap();
58-
let version = captures
56+
let version = re
57+
.captures(nvcc_str)
58+
.unwrap()
5959
.get(0)
6060
.expect("unable to find nvcc version in the form VMM.mm.pp in the output of `nvcc --version`:\n{nvcc_str}")
61-
.as_str()
61+
.as_str()[1..]
6262
.to_string();
6363
Some(version)
6464
} else {

0 commit comments

Comments
 (0)