+
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ mod cuda {
{
let start = std::time::Instant::now();

let compute_cap = {
// Grab compute code from nvidia-smi
let mut compute_cap = {
let out = std::process::Command::new("nvidia-smi")
.arg("--query-gpu=compute_cap")
.arg("--format=csv")
Expand All @@ -77,9 +78,38 @@ mod cuda {
let out = std::str::from_utf8(&out.stdout).unwrap();
let mut lines = out.lines();
assert_eq!(lines.next().unwrap(), "compute_cap");
lines.next().unwrap().replace('.', "")
let cap = lines.next().unwrap().replace('.', "");
cap.parse::<usize>().unwrap()
};

// Grab available GPU codes from nvcc and select the highest one
let max_nvcc_code = {
let out = std::process::Command::new("nvcc")
.arg("--list-gpu-code")
.output()
.unwrap();
let out = std::str::from_utf8(&out.stdout).unwrap();

let out = out.split("\n").collect::<Vec<&str>>();
let mut codes = Vec::with_capacity(out.len());
for code in out {
let code = code.split("_").collect::<Vec<&str>>();
if code.len() != 0 && code.contains(&"sm") {
if let Ok(num) = code[1].parse::<usize>() {
codes.push(num);
}
}
}
codes.sort();
*codes.last().unwrap()
};

// If nvidia-smi compute_cap is higher than the highest gpu code from nvcc,
// then choose the highest gpu code in nvcc
if compute_cap > max_nvcc_code {
compute_cap = max_nvcc_code;
}

println!("cargo:rustc-env=CUDA_COMPUTE_CAP=sm_{compute_cap}");

kernel_paths
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载