Skip to content

Commit 1f0a579

Browse files
authored
Update on Rust-CUDA progress (#67)
1 parent 073f00a commit 1f0a579

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed

blog/2025-03-18-rust-cuda-update.mdx

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
---
2+
title: "Rust CUDA project update"
3+
authors: [LegNeato]
4+
tags: ["announcement", "cuda"]
5+
---
6+
7+
import Gh from "@site/blog/src/components/UserMention";
8+
9+
The [Rust CUDA project](https://github.com/rust-gpu/rust-cuda) has been [rebooted after
10+
being dormant for 3+ years](./2025-01-27-rust-cuda-reboot.md).
11+
12+
Rust CUDA enables you to write and run [CUDA](https://developer.nvidia.com/cuda-toolkit)
13+
kernels in Rust, executing directly on NVIDIA GPUs using [NVVM
14+
IR](https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html).
15+
16+
Much has happened since the reboot announcement and we wanted to give an update.
17+
18+
**To follow along or get involved, check out the [`rust-cuda` repo on GitHub](https://github.com/rust-gpu/rust-cuda).**
19+
20+
<!-- truncate -->
21+
22+
## Short-term goals
23+
24+
As a reminder, our short-term goals were to stabilize and modernize the Rust CUDA
25+
project by updating dependencies, merging outstanding PRs, and closing outdated issues.
26+
27+
### Update to a newer Rust toolchain
28+
29+
Rust-CUDA is a collection of crates, one of which is
30+
[`rustc_codegen_nvvm`](https://github.com/Rust-GPU/Rust-CUDA/tree/main/crates/rustc_codegen_nvvm).
31+
This crate plugs directly into the Rust compiler to generate [NVVM
32+
IR](https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html), which NVIDIA's tools then
33+
compile down to GPU-executable code. It's the magic that makes Rust-on-GPU happen and
34+
allows your Rust code to call existing CUDA libraries (anything compiled into
35+
[PTX](https://docs.nvidia.com/cuda/parallel-thread-execution)).
36+
37+
Because `rustc_codegen_nvvm` relies heavily on the Rust compiler's internals, it needs
38+
to exactly match with a particular compiler version. Up until recently, Rust-CUDA was
39+
stuck on a very old nightly version—`nightly-2021-12-04`. That is **over 3 years old**!
40+
41+
Huge shoutout to new contributor <Gh user="jorge-ortega" /> for [bringing Rust-CUDA
42+
forward to `nightly-2025-03-02`](https://github.com/Rust-GPU/Rust-CUDA/pull/155). With
43+
this update, we've got much better compatibility with the Rust crate ecosystem and
44+
access to new language features.
45+
46+
Jorge used a [draft PR](https://github.com/Rust-GPU/Rust-CUDA/pull/98) put together by <Gh user="apriori" /> way back in 2022 as a guide. Big thanks to both <Gh user="jorge-ortega" /> and <Gh user="apriori" /> for making this leap possible!
47+
48+
### Experimental support for the latest CUDA tookit
49+
50+
The [latest NVIDIA CUDA toolkit is
51+
`12.x`](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html). When
52+
Rust-GPU was last maintained only `11.x` was available. Rust-GPU crates would error if
53+
CUDA was less than version `11.x`, but the check also errored on `12.x`. Supporting CUDA
54+
`12.x` is critical as most users install the latest CUDA toolkit.
55+
56+
<Gh user="jorge-ortega" /> tested Rust-GPU with CUDA `12.x` successfully, giving
57+
us confidence to enable initial support. New contributor <Gh user="Schmiedium" /> then
58+
[updated the version check](https://github.com/Rust-GPU/Rust-CUDA/pull/165), and
59+
maintainer <Gh user="LegNeato" /> integrated `12.x` [into CI](https://github.com/Rust-GPU/Rust-CUDA/pull/168).
60+
61+
Support for CUDA `12.x` remains experimental due to limited testing and ongoing codebase
62+
ramp-up. Please [file issues](https://github.com/Rust-GPU/Rust-CUDA/issues) if
63+
encountered!
64+
65+
### Fix CI
66+
67+
Rust-CUDA's CI was broken after three years of inactivity and there was significant
68+
technical debt.
69+
70+
As CI is critically important to quality, we focused on fixing and modernizing it. <Gh
71+
user="jorge-ortega" />, <Gh user="Schmiedium" />, and <Gh user="LegNeato" /> resolved
72+
formatting issues, fixed clippy warnings, updated dependencies, rewrote code, and
73+
addressed linker errors across both Windows and Linux. The [first passing CI
74+
run](https://github.com/Rust-GPU/Rust-CUDA/actions/runs/13913964011/) was a huge
75+
accomplishment and a culmination of a lot of debugging and development work.
76+
77+
The Rust-GPU project currently can't run GPU tests on GitHub Actions due to the lack of
78+
NVIDIA GPUs. **If you want to sponsor some CI machines, get in touch!**
79+
80+
Even without GPU tests, CI now provides a critical safety net for future development.
81+
82+
### Merging outstanding PRs
83+
84+
We merged over 16 outstanding pull requests from over 12 contributors as far back as 2022. Some selected changes:
85+
86+
- [#105](https://github.com/rust-gpu/rust-gpu/pull/105) by <Gh user="DoeringChristian"
87+
/>: Fixed a double-free caused by incorrect casting, significantly improving memory
88+
safety. While Rust-CUDA is written in Rust, we interface with CUDA libraries and tools
89+
written in C/C++ so issues like this can happen.
90+
- [#64](https://github.com/rust-gpu/rust-gpu/pull/64) by <Gh user="kjetilkjeka" /> (the
91+
`rustc` ptx backend maintainer): Added pitched memory allocation and 2D memcpy
92+
support, enabling more efficient GPU memory management.
93+
- [#67](https://github.com/rust-gpu/rust-gpu/pull/67) /
94+
[#68](https://github.com/rust-gpu/rust-gpu/pull/68) by <Gh user="chr1sj0nes" />:
95+
Removed unnecessary `Default` bounds, making the API better.
96+
- [#71](https://github.com/rust-gpu/rust-gpu/pull/71) by <Gh user="vmx" />: Added
97+
support for retrieving device UUID, making GPU resource management easier.
98+
99+
Thank you to all the (old) contributors:
100+
101+
<Gh user="zeroecco" />, <Gh user="skierpage" />, <Gh user="Vollkornaffe" />, <Gh user="Tweoss" />
102+
, <Gh user="DoeringChristian" />, <Gh user="ralfbiedert" />, <Gh user="vmx" />, <Gh user="jac-cbi" />
103+
, <Gh user="jounathaen" />, <Gh user="WilliamVenner" />, <Gh user="chr1sj0nes" />
104+
, <Gh user="kjetilkjeka" />
105+
106+
Sorry for your changes languishing for so long! We hope you come back and contribute
107+
again soon.
108+
109+
### Merging new PRs
110+
111+
Since the reboot, we merged over 22 new pull requests from over 7 new contributors:
112+
113+
<Gh user="Schmiedium" />, <Gh user="LegNeato" />, <Gh user="jorge-ortega" />, <Gh user="alaric728" />
114+
, <Gh user="Jerryy959" />, <Gh user="juntyr" />
115+
116+
Thank you to all of our new contributors!
117+
118+
#### Project cleanups
119+
120+
Rust-GPU maintainer <Gh user="LegNeato" /> went through the project and closed most of the
121+
outdated issues and any pull requests that were no longer relevant. Little things like
122+
tags on GitHub were added to aid discoverablility.
123+
124+
## What's next?
125+
126+
Now that the project is rebooted and stabilized, we can start to look forward. As
127+
mentioned in the [reboot post](./2025-01-27-rust-cuda-reboot.md), this is broadly what
128+
we are thinking:
129+
130+
- **Rust-C++ interop**: Investigate Rust's recent C++ interoperability initiatives to
131+
see if they can be used to simplify host and library integration for CUDA.
132+
- **Rust community collaboration**: Work with other Rust CUDA projects to consolidate
133+
and unify host-side tools and workflows where appropriate.
134+
- **PTX backend collaboration**: Coordinate with the [rustc PTX
135+
backend](https://doc.rust-lang.org/rustc/platform-support/nvptx64-nvidia-cuda.html)
136+
team to explore shared infrastructure and evaluate transitioning Rust CUDA from NVVM
137+
IR to raw PTX.
138+
- **`rust-gpu` collaboration**: Leverage `rust-gpu`'s tooling and compiler
139+
infrastructure to reduce duplication.
140+
141+
Of course, what's next will largely depend on who shows up and what they want to do!
142+
Rust-GPU is 100% community-driven; none of us are paid to work on it.
143+
144+
## Relation to other GPU projects in the Rust ecosystem
145+
146+
In the reboot post, we mentioned significant opportunities for collaboration and
147+
unification with related projects:
148+
149+
- **[Rust GPU](https://rust-gpu.github.io/)**: This project is similar to Rust CUDA but
150+
targets [SPIR-V](https://www.khronos.org/spir/) for [Vulkan](https://www.vulkan.org/)
151+
GPUs.
152+
153+
Our long-term vision for the two projects includes merging developer-facing APIs to
154+
provide a unified experience for GPU programming in Rust. Developers should not need
155+
to worry about underlying platforms (Vulkan vs. CUDA) or low-level IR (SPIR-V vs.
156+
NVVM) unless doing specialized work. This would make GPU programming in Rust feel as
157+
seamless as its abstractions for CPU architectures or operating systems.
158+
159+
Christian Legnitto ([LegNeato](https://github.com/LegNeato)) is one of the maintainers
160+
for both projects.
161+
162+
- **[`rustc` PTX
163+
backend](https://doc.rust-lang.org/rustc/platform-support/nvptx64-nvidia-cuda.html)**:
164+
The Rust compiler's experimental `nvptx` backend generates CUDA's low-level
165+
[PTX](https://docs.nvidia.com/cuda/parallel-thread-execution/) IR. We plan to
166+
collaborate with this effort to determine how it can complement or integrate with
167+
`rust-cuda`'s NVVM IR approach.
168+
169+
- **[cudarc](https://github.com/coreylowman/cudarc)**: This crate provides a host-side
170+
abstraction for CUDA programming in Rust. We aim to explore how `rust-cuda` can
171+
interoperate with `cudarc` or consolidate efforts.
172+
173+
After digging deeper into the Rust-CUDA codebase, we're even more convinced these
174+
opportunities are real. The path to merging Rust-CUDA and Rust-GPU, in particular, looks
175+
shorter and more relevant than we originally expected.
176+
177+
For a broader look at Rust and GPUs, check out the [ecosystem overview
178+
page](https://rust-gpu.github.io/ecosystem/).
179+
180+
## Call for contributors
181+
182+
We need your help to shape the future of CUDA programming in Rust. Whether you're a
183+
maintainer, contributor, or user, there's an opportunity to [get
184+
involved](https://github.com/rust-gpu/rust-cuda). We're especially
185+
interested in adding maintainers to make the project sustainable.
186+
187+
Be aware that the process may be a bit bumpy as we are still getting the project in
188+
order.
189+
190+
If you'd prefer to focus on non-proprietary and multi-vendor platforms, check out our
191+
related **[Rust GPU](https://rust-gpu.github.io/)** project. It is similar to Rust CUDA
192+
but targets [SPIR-V](https://www.khronos.org/spir/) for
193+
[Vulkan](https://www.vulkan.org/) GPUs.
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react";
2+
3+
interface UserMentionProps {
4+
user: string;
5+
}
6+
7+
const UserMention: React.FC<UserMentionProps> = ({ user }) => (
8+
<a href={`https://github.com/${user}`} rel="noopener noreferrer">
9+
@{user}
10+
</a>
11+
);
12+
13+
export default UserMention;

0 commit comments

Comments
 (0)