{"id":15030874,"url":"https://github.com/rust-gpu/rust-cuda","last_synced_at":"2025-05-14T08:02:12.247Z","repository":{"id":37301546,"uuid":"418282394","full_name":"Rust-GPU/Rust-CUDA","owner":"Rust-GPU","description":"Ecosystem of libraries and tools for writing and executing fast GPU code fully in Rust.","archived":false,"fork":false,"pushed_at":"2025-04-08T05:44:11.000Z","size":6232,"stargazers_count":4016,"open_issues_count":64,"forks_count":164,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-04-09T17:15:44.279Z","etag":null,"topics":["cuda","cuda-kernels","cuda-programming","gpgpu","gpu","gpu-programming","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rust-GPU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-17T23:37:05.000Z","updated_at":"2025-04-09T09:56:13.000Z","dependencies_parsed_at":"2023-01-29T22:31:16.083Z","dependency_job_id":"e89b683c-dd81-4d63-ae9d-0f60d0db572c","html_url":"https://github.com/Rust-GPU/Rust-CUDA","commit_stats":{"total_commits":187,"total_committers":12,"mean_commits":"15.583333333333334","dds":0.1871657754010695,"last_synced_commit":"8a6cb734d21d5582052fa5b38089d1aa0f4d582f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2FRust-CUDA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2FRust-CUDA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2FRust-CUDA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rust-GPU%2FRust-CUDA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rust-GPU","download_url":"https://codeload.github.com/Rust-GPU/Rust-CUDA/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250249170,"owners_count":21399410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","cuda-kernels","cuda-programming","gpgpu","gpu","gpu-programming","rust","rust-lang"],"created_at":"2024-09-24T20:14:26.112Z","updated_at":"2025-04-22T13:34:45.969Z","avatar_url":"https://github.com/Rust-GPU.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eThe Rust CUDA Project\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eAn ecosystem of libraries and tools for writing and executing extremely fast GPU code fully in\n    \u003ca href=\"https://www.rust-lang.org/\"\u003eRust\u003c/a\u003e\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003ch3\u003e\n    \u003ca href=\"https://rust-gpu.github.io/Rust-CUDA/guide/index.html\"\u003eGuide\u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"guide/src/guide/getting_started.md\"\u003eGetting Started\u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"guide/src/features.md\"\u003eFeatures\u003c/a\u003e\n  \u003c/h3\u003e\n\u003cstrong\u003e⚠️ The project is still in early development, expect bugs, safety issues, and things that don't work ⚠️\u003c/strong\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n\u003e [!IMPORTANT]\n\u003e This project is no longer dormant and is [being\n\u003e rebooted](https://rust-gpu.github.io/blog/2025/01/27/rust-cuda-reboot). Read the [latest status update](https://rust-gpu.github.io/blog/2025/03/18/rust-cuda-update).\n\u003e Please contribute!\n\n## Goal\n\nThe Rust CUDA Project is a project aimed at making Rust a tier-1 language for extremely fast GPU computing\nusing the CUDA Toolkit. It provides tools for compiling Rust to extremely fast PTX code as well as libraries\nfor using existing CUDA libraries with it.\n\n## Background\n\nHistorically, general purpose high performance GPU computing has been done using the CUDA toolkit. The CUDA toolkit primarily\nprovides a way to use Fortran/C/C++ code for GPU computing in tandem with CPU code with a single source. It also provides\nmany libraries, tools, forums, and documentation to supplement the single-source CPU/GPU code.\n\nCUDA is exclusively an NVIDIA-only toolkit. Many tools have been proposed for cross-platform GPU computing such as\nOpenCL, Vulkan Computing, and HIP. However, CUDA remains the most used toolkit for such tasks by far. This is why it is\nimperative to make Rust a viable option for use with the CUDA toolkit.\n\nHowever, CUDA with Rust has been a historically very rocky road. The only viable option until now has been to use the LLVM PTX\nbackend, however, the LLVM PTX backend does not always work and would generate invalid PTX for many common Rust operations, and\nin recent years it has been shown time and time again that a specialized solution is needed for Rust on the GPU with the advent\nof projects such as rust-gpu (for Rust -\u003e SPIR-V).\n\nOur hope is that with this project we can push the Rust GPU computing industry forward and make Rust an excellent language\nfor such tasks. Rust offers plenty of benefits such as `__restrict__` performance benefits for every kernel, An excellent module/crate system,\ndelimiting of unsafe areas of CPU/GPU code with `unsafe`, high level wrappers to low level CUDA libraries, etc.\n\n## Structure\n\nThe scope of the Rust CUDA Project is quite broad, it spans the entirety of the CUDA ecosystem, with libraries and tools to make it\nusable using Rust. Therefore, the project contains many crates for all corners of the CUDA ecosystem.\n\nThe current line-up of libraries is the following:\n\n- `rustc_codegen_nvvm` Which is a rustc backend that targets NVVM IR (a subset of LLVM IR) for the [libnvvm](https://docs.nvidia.com/cuda/nvvm-ir-spec/index.html) library.\n  - Generates highly optimized PTX code which can be loaded by the CUDA Driver API to execute on the GPU.\n  - For the near future it will be CUDA-only, but it may be used to target amdgpu in the future.\n- `cuda_std` for GPU-side functions and utilities, such as thread index queries, memory allocation, warp intrinsics, etc.\n  - _Not_ a low level library, provides many utility functions to make it easier to write cleaner and more reliable GPU kernels.\n  - Closely tied to `rustc_codegen_nvvm` which exposes GPU features through it internally.\n- [`cudnn`](https://github.com/Rust-GPU/Rust-CUDA/tree/master/crates/cudnn) for a collection of GPU-accelerated primitives for deep neural networks.\n- `cust` for CPU-side CUDA features such as launching GPU kernels, GPU memory allocation, device queries, etc.\n  - High level with features such as RAII and Rust Results that make it easier and cleaner to manage the interface to the GPU.\n  - A high level wrapper for the CUDA Driver API, the lower level version of the more common CUDA Runtime API used from C++.\n  - Provides much more fine grained control over things like kernel concurrency and module loading than the C++ Runtime API.\n- `gpu_rand` for GPU-friendly random number generation, currently only implements xoroshiro RNGs from `rand_xoshiro`.\n- `optix` for CPU-side hardware raytracing and denoising using the CUDA OptiX library.\n\nIn addition to many \"glue\" crates for things such as high level wrappers for certain smaller CUDA libraries.\n\n## Related Projects\n\nOther projects related to using Rust on the GPU:\n\n- 2016: [glassful](https://github.com/kmcallister/glassful) Subset of Rust that compiles to GLSL.\n- 2017: [inspirv-rust](https://github.com/msiglreith/inspirv-rust) Experimental Rust MIR -\u003e SPIR-V Compiler.\n- 2018: [nvptx](https://github.com/japaric-archived/nvptx) Rust to PTX compiler using the `nvptx` target for rustc (using the LLVM PTX backend).\n- 2020: [accel](https://github.com/termoshtt/accel) Higher-level library that relied on the same mechanism that `nvptx` does.\n- 2020: [rlsl](https://github.com/MaikKlein/rlsl) Experimental Rust -\u003e SPIR-V compiler (predecessor to rust-gpu)\n- 2020: [rust-gpu](https://github.com/Rust-GPU/rust-gpu) `rustc` compiler backend to compile Rust to SPIR-V for use in shaders, similar mechanism as our project.\n\n## Usage\n```bash\n## setup your environment like:\n### export OPTIX_ROOT=/opt/NVIDIA-OptiX-SDK-9.0.0-linux64-x86_64\n### export OPTIX_ROOT_DIR=/opt/NVIDIA-OptiX-SDK-9.0.0-linux64-x86_64\n\n## build proj\ncargo build\n```\n\n## Use Rust-CUDA in Container Environments\n\nThe distribution related Dockerfile are located in `container` folder.\nTaking ubuntu 24.04 as an example, run the following command in repository root:\n```bash\ndocker build -f ./container/ubuntu24/Dockerfile -t rust-cuda-ubuntu24 .\ndocker run --rm --runtime=nvidia --gpus all -it rust-cuda-ubuntu24\n```\n\nA sample `.devcontainer.json` file is also included, configured for Ubuntu 24.02. Copy this to `.devcontainer/devcontainer.json` to make additonal customizations.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your discretion.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-gpu%2Frust-cuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-gpu%2Frust-cuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-gpu%2Frust-cuda/lists"}