I don’t have a system with multiple GPUs, so I haven’t really worked on a decent multi-GPU API.
But what I assume is happening here, is that you aren’t executing this code in separate processes. CUDA is an API with global state, and the
CuContext(dev) call sets the global context for all subsequent API calls.
Maybe try the following (again, untested, but I think it should work):
@everywhere using CUDAdrv, CUDAnative
@everywhere function expensiveFunction()
@everywhere function calculateStuff(gpuId)
dev = CuDevice(gpuId)
CuContext(dev) do ctx
s1 = @spawnat 1 calculateStuff(0)
s2 = @spawnat 2 calculateStuff(1)
I’m not too familiar with
@everyone feel free to correct my use of the library.