chelsea0x3b/cudarc
Safe rust wrapper around CUDA toolkit
What it solves
It provides a minimal and safe Rust API for interacting with the NVIDIA CUDA toolkit, allowing developers to leverage GPU acceleration without dealing directly with the raw, unsafe C-style FFI (Foreign Function Interface) calls typically required for CUDA development.
How it works
cudarc creates a layered wrapper system around the CUDA toolkit libraries. It offers three levels of access:
- sys: Raw FFI APIs generated via bindgen.
- result: A thin wrapper that converts CUDA function returns into Rust
Resulttypes. - safe: High-level, ergonomic abstractions that prioritize safety and ease of use.
It supports a wide range of CUDA libraries including the Driver API, NVRTC (runtime compilation), cuBLAS, cuDNN, NCCL, and others. It also allows for flexible linking options (dynamic loading, dynamic linking, or static linking) and supports multiple CUDA versions.
Who it’s for
Rust developers who want to write high-performance GPU kernels and manage CUDA resources (like memory allocation and data transfer) using a safe, idiomatic Rust interface.
Highlights
- Broad Library Support: Wrappers for essential CUDA tools like cuBLAS, cuDNN, NCCL, and cuSPARSE.
- Runtime Compilation: Integration with NVRTC to compile CUDA kernels at runtime.
- Flexible Configuration: Support for multiple CUDA and cuDNN versions via feature flags.
- Ergonomic Kernel Launching: Uses a builder pattern to specify kernel arguments and launch configurations.
Related
- Dispatch
- Project
- Dispatch
- Project
- Dispatch