r/learnrust • • 9d ago

How can you write vendor-independent gpu code ?

Hello !
I have a small question, i have a project where i need to write GPU code and I would like to support both AMD and NVIDIA cards. When browsing the web I found that rocm seems to have HIP which seems to fulfill this role but I cannot find any crate providing bindings for it, could you give me some pointers ?
have a nice day !

2 Upvotes

3 comments sorted by

2

u/pdpi 9d ago

You could look at Vulkan or WGPU compute shaders.

1

u/Docredstone1 2d ago

Nice, that looks promising, do you know if there exists crate that has a similar interface to cuda-oxide for the compute ? In any case, thank you very much for this advice !

2

u/Discordbothost 9d ago

If you're writing your own kernels, wgpu can dispatch the same WGSL compute shader through Vulkan on both vendors. I'd port one representative kernel first and run it on both target cards. Check the adapter's features and limits before leaning on things like subgroups or 16-bit floats.