#cuda #gpu #api-bindings #cudarc

cuda_setup

Assists with CUDA setup when using the CUDARC lib

2 releases

new 0.1.1 Mar 8, 2025
0.1.0 Jan 27, 2025

#1145 in Hardware support

Download history 100/week @ 2025-01-27 23/week @ 2025-02-03 1/week @ 2025-02-10 17/week @ 2025-02-17 1/week @ 2025-02-24 56/week @ 2025-03-03

76 downloads per month

MIT license

6KB

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

No runtime deps