#cuda #gpu #api-bindings #cudarc

cuda_setup

Assists with CUDA setup when using the CUDARC lib

1 unstable release

new 0.1.0 Jan 27, 2025

#1031 in Hardware support

Download history 76/week @ 2025-01-22

76 downloads per month

MIT license

5KB

Code to make working with CUDA, via the CUDARC lib, easier.

Crate Docs

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.
    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"

No runtime deps