CUDA programming in Julia
The CUDA.jl package is the main programming interface for working with NVIDIA CUDA GPUs using Julia. It features a user-friendly array abstraction, a compiler for writing CUDA kernels in Julia, and wrappers for various CUDA libraries.
Before all, make sure you have a recent NVIDIA driver. On Windows, also make sure you have the Visual C++ redistributable installed. You do not need to install the CUDA Toolkit.
CUDA.jl can be installed with the Julia package manager. From the Julia REPL, type ] to
enter the Pkg REPL mode and run:
pkg> add CUDA
Or, equivalently, via the Pkg API:
julia> import Pkg; Pkg.add("CUDA")For an overview of the CUDA toolchain in use, you can run the following command after importing the package:
julia> using CUDA
julia> CUDA.versioninfo()This may take a while, as it will precompile the package and download a suitable version of the CUDA toolkit. If your GPU is not fully supported, the above command (or any other command that initializes the toolkit) will issue a warning.
For quick testing, you can also use the juliagpu/cuda.jl container
image from the GitHub
Container Registry, which provides Julia, a precompiled version of CUDA.jl, and a matching
CUDA toolkit. Tags are named after the CUDA major version (cuda12 or cuda13); the
bare tag tracks the latest stable release, while <version>-cuda<major> pins to a
specific release and dev-cuda<major> tracks the latest main build:
# latest stable release, CUDA 13
docker run -it --rm --gpus=all ghcr.io/juliagpu/cuda.jl:cuda13
# a specific release, CUDA 12
docker run -it --rm --gpus=all ghcr.io/juliagpu/cuda.jl:v6.1.0-cuda12
# latest main build, CUDA 13
docker run -it --rm --gpus=all ghcr.io/juliagpu/cuda.jl:dev-cuda13For more usage instructions and other information, please refer to the documentation.
From version 6.0 on, CUDA.jl is a meta-package the imports the following registered subpackages:
- CUDACore: the core package with the main CUDA API wrappers and the compiler for writing CUDA kernels in Julia;