Most active commenters
  • shmerl(5)
  • pjmlp(5)
  • coffeeaddict1(5)
  • keldaris(4)
  • fragmede(3)

←back to thread

Rust CUDA Project

(github.com)
146 points sksxihve | 28 comments | | HN request time: 3.249s | source | bottom
1. shmerl ◴[] No.43656833[source]
Looks like a dead end. Why CUDA? There should be some way to use Rust for GPU programming in general fashion, without being tied to Nvidia.
replies(5): >>43656967 #>>43657008 #>>43657034 #>>43658709 #>>43659892 #
2. kouteiheika ◴[] No.43656967[source]
There's no cross-vendor API which exposes the full power of the hardware. For example, you can use Vulkan to do compute on the GPU, but it doesn't expose all of the features that CUDA exposes, and you need to do the legwork yourself reimplementing all of the well optimized libraries (like e.g. cublas or cudnn) that you get for free with CUDA.
replies(1): >>43658043 #
3. the__alchemist ◴[] No.43657008[source]
CUDA is the easiest-to-use and most popular GPGPU framework. I agree that it's unfortunate there aren't good alternatives! As kouteiheika pointed out, you can use Vulkan (Or OpenCL), but they are not as pleasant.
replies(1): >>43658049 #
4. pjmlp ◴[] No.43657034[source]
Because others so far have failed to deliver anything worthwhile using, with the same tooling ecosystem as CUDA.
replies(3): >>43657851 #>>43658002 #>>43658007 #
5. coffeeaddict1 ◴[] No.43657851[source]
While I agree, that CUDA is the best in class API for GPU programming, OpenCL, Vulkan compute shaders and Sycl are alternatives that are usable. I'm for example, using compute shaders for writing GPGPU algorithms that work on Mac, AMD, Intel and Nvidia. It works ok. The debugging experience and ecosystem sucks compared to CUDA, but being able to run the algorithms across platforms is a huge advantage over CUDA.
replies(3): >>43658021 #>>43658035 #>>43658602 #
6. ◴[] No.43658002[source]
7. shmerl ◴[] No.43658007[source]
To deliver, you need to make Rust target the GPU in a general way, like some IR, and then may be compile that into GPU machine code for each GPU architecture specifically.

So this project is a dead end, because it's them who are these "others" - they are developing it and they are doing it wrong.

replies(1): >>43658699 #
8. keldaris ◴[] No.43658021{3}[source]
How are you writing compute shaders that work on all platforms, including Mac? Are you just writing Vulkan and relying on MoltenVK?

AFAIK, the only solution that actually works on all major platforms without additional compatibility layers today is OpenCL 1.2 - which also happens to be officially deprecated on MacOS, but still works for now.

replies(2): >>43658633 #>>43658666 #
9. fragmede ◴[] No.43658035{3}[source]
why do you need to run across all those platforms? what's the cost benefit for doing so?
replies(1): >>43658724 #
10. shmerl ◴[] No.43658043[source]
Make a compiler that takes Rust and compiles into some IR, then another compiler that compiles that IR into GPU machine code. Then it can work and that's going to be your API (what you developed in Rust).

That's the whole point of what's missing. Not some wrapper around CUDA.

11. shmerl ◴[] No.43658049[source]
It defeats the purpose. Easy to use should be something in Rust, not CUDA.
replies(1): >>43660550 #
12. pjmlp ◴[] No.43658602{3}[source]
No they aren't, because they lack the polyglot support from CUDA and as you acknowledge the debugging experience and ecosystem sucks.
13. pjmlp ◴[] No.43658633{4}[source]
And is stuck with C99, versus C++20, Fortran, Julia, Haskell, C#, anything else someone feels like targeting PTX with.
replies(1): >>43658760 #
14. coffeeaddict1 ◴[] No.43658666{4}[source]
Yes, MoltenVK works fine. Alternatively, you can also use WebGPU (there are C++ and Rust native libs) which is a simpler but more limiting API.
replies(1): >>43658775 #
15. pjmlp ◴[] No.43658699{3}[source]
Plus IDE support, Nsight level debugging, GPU libraries, yes most likely bound to fail unless NVidia, like it happened with other languages sees enough business value to give an helping hand.

They are already using Rust in Dynamo, even though the public API is Python.

16. ◴[] No.43658709[source]
17. coffeeaddict1 ◴[] No.43658724{4}[source]
Well it really depends on the kind of work you're doing. My (non-AI) software allows users to run my algorithms on whatever server-side GPU or local device they have. This is a big advantage IMO.
replies(1): >>43659681 #
18. keldaris ◴[] No.43658760{5}[source]
Technically, OpenCL can also include inline PTX assembly in kernels (unlike any compute shader API I've ever seen), which is relevant for targeting things like tensor cores. You're absolutely right about the language limitation, though.
replies(1): >>43662463 #
19. keldaris ◴[] No.43658775{5}[source]
WebGPU has no support for tensor cores (or their Apple Silicon equivalents). Vulkan has an Nvidia extension for it, is there any way to make MoltenVK use simdgroup_matrix instructions in compute shaders?
replies(1): >>43658912 #
20. coffeeaddict1 ◴[] No.43658912{6}[source]
AFAIK, MoltenVK doesn't. Dawn (Google's C++ WebGPU implementation) does have some experimental support for it [0][1].

[0] https://issues.chromium.org/issues/348702031

[1] https://github.com/gpuweb/gpuweb/issues/4195

21. fragmede ◴[] No.43659681{5}[source]
interesting! Can you say more about what kind of algorithms your software runs?
replies(1): >>43662446 #
22. LegNeato ◴[] No.43659892[source]
You can look to https://github.com/Rust-GPU/rust-gpu/ for vulkan.
replies(1): >>43688827 #
23. adastra22 ◴[] No.43660550{3}[source]
The purpose is to get shit done.
24. coffeeaddict1 ◴[] No.43662446{6}[source]
My work is primarily about the processing of medical images (which usually are large 3D images). Doing this on the GPU, can be up to 10-20x faster.
replies(1): >>43667306 #
25. pjmlp ◴[] No.43662463{6}[source]
At which point why bother, PTX is CUDA.
replies(1): >>43666392 #
26. keldaris ◴[] No.43666392{7}[source]
Generally, the reason to bother with this approach is if you have a project that only needs tensor cores in a tiny part of the code and otherwise benefits from the cross platform nature of OpenCL, so you have a mostly shared codebase with a small vendor-specific optimization in a kernel or two. I've been in that situation and do find that approach valuable, but I'll be the first to admit the modern GPGPU landscape is full of unpleasant compromises whichever way you look.
27. fragmede ◴[] No.43667306{7}[source]
But what about that wants to be multi-platform instead of picking one an specializing, probably picking up some more optimizations along the way?
28. shmerl ◴[] No.43688827[source]
That's a good example of of what it should be.