deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

Nvidia brings native CUDA GPU programming to Rust with two-track support

Nvidia now supports writing CUDA kernels in Rust through a low-level track that mirrors CUDA C++ and a high-level iterator-style API, replacing years of reliance on community crates.

Nvidia brings native CUDA GPU programming to Rust with two-track support

What Nvidia announced

According to a practical guide published on dev.to, Nvidia has introduced native GPU programming support for Rust, ending the language's long status as a third-party afterthought in the CUDA ecosystem. The support is structured as a "two tracks" model aimed at two very different audiences.

The first track is low-level CUDA Rust. It closely mirrors CUDA C++ semantics, giving kernel authors direct control over thread blocks, shared memory, warps and memory coalescing. The intent, per the guide, is familiarity: engineers porting existing CUDA codebases should find the shape of a Rust kernel nearly identical to its C++ counterpart.

The second track is a high-level abstraction. It provides an ergonomic, iterator-based API that the guide compares to rayon, the well-known CPU parallelism library, compiling down to efficient kernels without forcing developers to hand-manage grid and block dimensions for every operation.

From community crates to first-party backing

Until now, GPU work in Rust depended on unofficial projects. The guide names the main options: rust-cuda, which builds PTX through the nvptx64-nvidia-cuda target; wgpu, aimed at cross-platform compute shaders; and cudarc, offering safer bindings to the CUDA driver API.

These crates worked, but none carried Nvidia's endorsement, which in practice meant no guaranteed compatibility with new CUDA toolkit releases, no first-party debugging through cuda-gdb or Nsight, and recurring breakage across driver updates. Official backing, the guide argues, gives Rust kernels the kind of tooling maturity C++ has enjoyed since CUDA arrived in 2007.

Where Rust helps, and where it does not

The dev.to guide tempers expectations on performance: kernels do not get faster simply because they are written in Rust, since the GPU executes PTX regardless of which language produced it. The payoff sits on the host side, in the allocation, launch and data-transfer code where most CUDA bugs have historically lived. The guide points to use-after-free bugs on device pointers, mismatched grid dimensions and missed cleanup calls as typical examples.

The concrete gains it lists include borrow checking that prevents data races in host code, typed error handling through Result and the ? operator instead of manually inspected error codes, unified package management via Cargo, and stronger compile-time verification of kernel launches.

Limitations remain. Nsight integration is described as still in progress, with PTX-level debugging available today, and interop with existing C++ CUDA libraries such as cuDNN and cuBLAS still requires bindgen or the cxx crate.

Getting a kernel running

The setup described in the guide requires the nightly Rust toolchain, the rust-src component, the nvptx64-nvidia-cuda target and a local CUDA toolkit installation. Track One kernels are built with no_std and intrinsics from the core::arch::nvptx module, and the resulting vector-addition example reads almost line for line like the equivalent CUDA C++ function. Host code loads the compiled PTX module, allocates device buffers and launches through a macro, with every fallible call returning a typed error instead of a silent failure.

Track Two strips even that away. The guide's example uploads two vectors to the device, combines them with zip and map, and collects the result, with no grid or block arithmetic, no manual PTX compilation step and no explicit stream synchronisation.

Why it matters

For teams building GPU-accelerated infrastructure, from ML training pipelines to data processing engines and custom inference servers, the announcement changes the calculus for adopting Rust. Memory safety no longer has to be traded away against raw throughput or vendor-grade tooling, and the split between a control-oriented track and an ergonomic one mirrors Rust's own safe-versus-unsafe philosophy. It also opens GPU acceleration to application developers who never intended to become CUDA architecture experts, while leaving kernel specialists the low-level access they need.

  • #rust
  • #nvidia
  • #cuda
  • #gpu
  • #systems-programming

Related posts