I copy and paste the DiffEqFlux.jl GPU example, slap in an @time on the sciml_train call at the end and spin it up. The runtime is reported on my system as around 38 seconds.
I then edit the example to be fully CPU, and the runtime is around 2.5 seconds.
Is this example expected to be much slower on the GPU? e.g. maybe because it is a small problem size and the overhead of copies to and from GPU memory is a bottleneck? Do others experience the same performance issues with this example?
I had CUDA Toolkit already installed on my device before I started trying out Julia. Output of CUDA.versioninfo():
It’s not a performance issue. It’s just because CPU matmuls of that size are faster on CPU. Did you try
A = rand(50,50)
b = rand(50)
gA = gpu(A)
gb = gpu(b)
You can make the example bigger and bigger until GPUs finally make sense. You need pretty big problems for GPUs to make sense if the CPU code is optimized. You can also batch data points which would help here.
Indeed the matrix multiplication test gives appropriate speed-up on my device as the size grows. So yes my GPU is working as expected - I just wanted to confirm that example was meant primarily to show you how to use the GPU, and not for demonstrating performance gains.
(P.S. if you can point me to GPU example using DiffEqFlux that does yield performance gains, that would be great!)
Solving Systems of Stochastic PDEs and using GPUs in Julia - Stochastic Lifestyle is a good example for GPUs, though not necessarily a neural ODE one.The problem here is that very optimized CPU code does pretty well on neural ODEs and UDEs until you make them asymptotically big. MNIST and the like can be a good example, or PDE-constrained optimization is probably a more realistic one. I think this is probably a good starting point for a GSoC. IIRC the PDE example from the UDE paper is a good one for GPUs.