Skip to content

Commit b9f8063

Browse files
committed
Add usage example.
Closes JuliaGPU#28.
1 parent 319a71e commit b9f8063

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
**GPU integrations for Dagger.jl**
44

5-
DaggerGPU.jl makes use of the `Dagger.Processor` infrastructure to dispatch Dagger kernels to NVIDIA, AMD, and Apple GPUs, via CUDA.jl, AMDGPU.jl, and Metal.jl respectively. Usage is simple: `add` or `dev` DaggerGPU.jl and CUDA.jl/AMDGPU.jl/Metal.jl appropriately, load it with `using DaggerGPU`, and add `DaggerGPU.CuArrayDeviceProc`/`DaggerGPU.ROCArrayProc`/`DaggerGPU.MtlArrayDeviceProc` to your scheduler or thunk options (see Dagger.jl documentation for details on how to do this).
5+
DaggerGPU.jl makes use of the `Dagger.Processor` infrastructure to dispatch Dagger kernels to NVIDIA, AMD, and Apple GPUs, via CUDA.jl, AMDGPU.jl, and Metal.jl respectively. Usage is simple: `add` or `dev` DaggerGPU.jl and CUDA.jl/AMDGPU.jl/Metal.jl appropriately, load it with `using DaggerGPU`, and add the appropriate GPU scope to the Dagger scope options, for example
6+
7+
``` julia
8+
using CUDA, Dagger, DaggerGPU
9+
sc = Dagger.scope(cuda_gpu=1)
10+
11+
# two large matrices
12+
A = rand(1000, 1000); B = rand(1000, 1000)
13+
# move them to gpu and multiply there
14+
A_gpu = Dagger.@spawn scope=sc CUDA.Matrix(A); B_gpu = Dagger.@spawn scope=sc CUDA.Matrix(B)
15+
C_gpu = Dagger.@spawn scope=sc A_gpu*B_gpu
16+
# move back to cpu to use there.
17+
C = Dagger.@spawn scope=sc Matrix(C_gpu)
18+
```
19+
20+
and similarly for `rocm_gpu` and `metal_gpu`.
621

722
DaggerGPU.jl is still experimental, but we welcome GPU-owning users to try it out and report back on any issues or sharp edges that they encounter. When filing an issue about DaggerGPU.jl, please provide:
823
- The complete error message and backtrace

0 commit comments

Comments
 (0)