2 releases
new 0.1.1 | Mar 8, 2025 |
---|---|
0.1.0 | Jan 27, 2025 |
#1145 in Hardware support
76 downloads per month
6KB
Code to make working with CUDA, via the CUDARC lib, easier.
This library abstracts over some of the boilerplate needed to use the Cudarc library, for using CUDA GPU compute in the rust language.
To use, create a build.rs
file like this:
//! We use this to automatically compile CUDA C++ code when building.
use cuda_setup::{build, GpuArchitecture};
fn main() {
// The second parameter is a list of paths to all kernels to compile.
// The first kernel passed must be the top-level one. All others are just to watch for changes to trigger
// a new compilation.
build(GpuArchitecture::Rtx4, &vec!["src/cuda/cuda.cu", "src/cuda/util.cu"]);
}
Or if your application has CUDA feature-gated:
//! We use this to automatically compile CUDA C++ code when building.
#[cfg(feature = "cuda")]
use cuda_setup::{build, GpuArchitecture};
fn main() {
#[cfg(feature = "cuda")]
build(GpuArchitecture::Rtx4, &vec!["src/cuda/cuda.cu", "src/cuda/util.cu"]);
}
Include this in Cargo.toml
:
[dependencies]
cudarc = { version = "^0.13.3",features=["cuda-12060"] }
[build-dependencies]
cuda_setup = "^0.1.0"