The cuda-oxide Book

Lobsters Hottest Tools

Summary

cuda-oxide is an experimental Rust-to-CUDA compiler that allows developers to write safe, idiomatic Rust GPU kernels that compile directly to PTX.

<p><a href="https://lobste.rs/s/h7nu14/cuda_oxide_book">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 05/08/26, 09:34 AM

# The cuda-oxide Book — cuda-oxide Source: [https://nvlabs.github.io/cuda-oxide/](https://nvlabs.github.io/cuda-oxide/) [![cuda-oxide logo](https://nvlabs.github.io/cuda-oxide/_images/logo.png)](https://nvlabs.github.io/cuda-oxide/_images/logo.png)**cuda\-oxide**is an experimental Rust\-to\-CUDA compiler that lets you write \(SIMT\) GPU kernels in safe\(ish\), idiomatic Rust\. It compiles standard Rust code directly to PTX — no DSLs, no foreign language bindings, just Rust\. Note This book assumes familiarity with the Rust programming language, including ownership, traits, and generics\. Later chapters on async GPU programming also assume working knowledge of`async`/`\.await`and runtimes like tokio\. For a refresher, see[The Rust Programming Language](https://doc.rust-lang.org/book/),[Rust by Example](https://doc.rust-lang.org/rust-by-example/), or the[Async Book](https://rust-lang.github.io/async-book/)\. --- ## Project Status[\#](https://nvlabs.github.io/cuda-oxide/#project-status) The v0\.1\.0 release is an early\-stage alpha:**expect bugs, incomplete features, and API breakage**as we work to improve it\. We hope you’ll try it and help shape its direction by sharing feedback on your experience\. --- ## 🚀 Quick start[\#](https://nvlabs.github.io/cuda-oxide/#quick-start) ``` use cuda_device::{kernel, thread, DisjointSlice}; use cuda_core::{CudaContext, DeviceBuffer, LaunchConfig}; use cuda_host::{cuda_launch, load_kernel_module}; #[kernel] fn vecadd(a: &[f32], b: &[f32], mut c: DisjointSlice<f32>) { let idx = thread::index_1d(); if let Some(c_elem) = c.get_mut(idx) { *c_elem = a[idx.get()] + b[idx.get()]; } } fn main() { let ctx = CudaContext::new(0).unwrap(); let stream = ctx.default_stream(); let module = load_kernel_module(&ctx, "vecadd").unwrap(); let a = DeviceBuffer::from_host(&stream, &[1.0f32; 1024]).unwrap(); let b = DeviceBuffer::from_host(&stream, &[2.0f32; 1024]).unwrap(); let mut c = DeviceBuffer::<f32>::zeroed(&stream, 1024).unwrap(); cuda_launch! { kernel: vecadd, stream: stream, module: module, config: LaunchConfig::for_num_elems(1024), args: [slice(a), slice(b), slice_mut(c)] }.unwrap(); let result = c.to_host_vec(&stream).unwrap(); assert_eq!(result[0], 3.0); } ``` Build and run with`cargo oxide run vecadd`upon installing the[prerequisites](https://nvlabs.github.io/cuda-oxide/getting-started/installation.html)\. Note The module name passed to`load\_kernel\_module`is the kernel artifact basename; for workspace examples that is the example name\. --- ## Why cuda\-oxide?[\#](https://nvlabs.github.io/cuda-oxide/#why-cuda-oxide) 🦀 Rust on the GPU Write GPU kernels with Rust’s type system and ownership model\. Safety is a first\-class goal, but GPUs have subtleties — read about[the safety model](https://nvlabs.github.io/cuda-oxide/gpu-safety/the-safety-model.html)\. 💎 A SIMT Compiler Not a DSL\. A custom rustc codegen backend that compiles pure Rust to PTX\. ⚡ Async Execution Compose GPU work as lazy`DeviceOperation`graphs\. Schedule across stream pools\. Await results with`\.await`\.

Similar Articles

CUDA-oxide: Nvidia's official Rust to CUDA compiler

Hacker News Top

CUDA-oxide is an experimental Rust-to-CUDA compiler developed by NVIDIA that enables writing safe GPU kernels in idiomatic Rust, compiling directly to PTX without requiring domain-specific languages or foreign bindings.

Show HN: cuTile Rust: Safe, data-race-free GPU kernels in Rust

Hacker News Top

NVIDIA Labs releases cuTile Rust, a tile-based system for writing memory-safe, data-race-free GPU kernels in idiomatic Rust. It extends Rust's ownership model to GPU kernels, JIT-compiles Rust AST to GPU code, and achieves performance close to native CUDA.

GPU Offload in Rust: Portable, Safe, and Fast

Hacker News Top

This paper presents a zero-overhead, multi-vendor GPU compilation framework built into the Rust compiler, leveraging Rust's ownership model to ensure memory safety and achieve competitive performance with native CUDA and HIP baselines.