fn main() {
println!("cargo:rerun-if-changed=src/cuda_kernels/activation.cu");
println!("cargo:rerun-if-changed=build.rs");
#[cfg(target_os = "linux")]
{
let output = std::process::Command::new("nvcc").arg("--version").output();
if let Ok(output) = output {
if output.status.success() {
cc::Build::new()
.cuda(true)
.cudart("shared") .flag("-gencode")
.flag("arch=compute_75,code=sm_75") .file("src/cuda_kernels/activation.cu")
.compile("tl_cuda_kernels");
println!("cargo:rustc-link-lib=dylib=cudart");
println!("cargo:rustc-link-lib=dylib=cuda");
} else {
println!(
"cargo:warning=nvcc found but failed version check. Skipping CUDA kernel compilation."
);
}
} else {
panic!(
"\n\n\
========================================\n\
ERROR: nvcc not found!\n\
========================================\n\
\n\
CUDA feature is enabled but nvcc (NVIDIA CUDA Compiler) was not found in PATH.\n\
\n\
To fix this:\n\
\n\
1. Install CUDA Toolkit from:\n\
https://developer.nvidia.com/cuda-downloads\n\
\n\
2. Add nvcc to your PATH:\n\
export PATH=/usr/local/cuda/bin:$PATH\n\
\n\
3. Verify installation:\n\
nvcc --version\n\
\n\
========================================\n"
);
}
}
}