4 releases
Uses new Rust 2024
new 0.1.4 | May 13, 2025 |
---|---|
0.1.3 | May 10, 2025 |
0.1.1 | Mar 8, 2025 |
0.1.0 | Jan 27, 2025 |
#465 in Hardware support
120 downloads per month
7KB
51 lines
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"] }
# For runtime conveniences.
cuda_setup = { version = "^0.1.2", features = ["cuda-12060"] }
[build-dependencies]
# For compiling kernels to PTX.
cuda_setup = { version = "^0.1.2", features = ["cuda-12060"] }