Skip to content

AMDGPU.jlProgramming AMD GPUs with Julia

AMDGPU.jl

Install ​

Simply add the AMDGPU.jl package to your Julia environment:

julia
using Pkg

Pkg.add("AMDGPU")

Requirements ​

  • Julia 1.10+

  • MI300X requires Julia 1.12+

  • 64-bit Linux or Windows

  • An AMD GPU driver: the amdgpu kernel driver on Linux, AMD Software: Adrenalin Edition on Windows

The ROCm runtime and libraries are downloaded automatically, matching the GPUs detected on the host, so no ROCm installation is needed. To use a ROCm installed on the system instead, or when no GPU is visible at install time, see Installation.

Test ​

To ensure that everything works, you can run the test suite:

julia
using AMDGPU
using Pkg

Pkg.test("AMDGPU")

Example ​

Element-wise addition via high-level interface & low-level kernel:

julia
using AMDGPU

function vadd!(c, a, b)
   i = workitemIdx().x + (workgroupIdx().x - 1) * workgroupDim().x
   if i ≤ length(a)
       c[i] = a[i] + b[i]
   end
   return
end

a = AMDGPU.ones(Int, 1024)
b = AMDGPU.ones(Int, 1024)
c = AMDGPU.zeros(Int, 1024)

groupsize = 256
gridsize = cld(length(c), groupsize)
@roc groupsize=groupsize gridsize=gridsize vadd!(c, a, b)

@assert (a .+ b) ≈ c

Questions and Contributions ​

Usage questions can be posted on the Julia Discourse forum under the GPU domain and/or in the #gpu channel of the Julia Slack.

Contributions are very welcome, as are feature requests and suggestions. Please open an issue if you encounter any problems.

Acknowledgment ​

AMDGPU.jl would not have been possible without the work by Tim Besard and contributors to CUDA.jl and LLVM.jl.

License ​

AMDGPU.jl is licensed under the MIT License.