Persist data on GPU between parfor Calls
Mostrar comentarios más antiguos
The actual overhead from invoking a parfor is pretty low (~17 ms), so it is fast enough to start up a parfor, do one operation per worker, and then repeat:
for i=1:N
parfor j=1:10
X{j} = gpuArray(X{j});
Y{j} = MyFunction(X{j}); % <-- Takes about 1 second per worker
end
end
However, it seems that Matlab re-copies all of the data in X{j} over to the GPU each iteration of the for loop. I would like X{j} to persist on the GPU between for loop iterations.
One hacky solution is to embed another for loop inside the parfor to reduce the amount of re-copying. This is not ideal for my application (I'm doing gradient descent function optimization).
Hopefully there is a simple way to force each X{j} to remain on its respective GPU.
Respuesta aceptada
Más respuestas (1)
Jonathan
el 7 de Abr. de 2015
0 votos
1 comentario
Edric Ellis
el 8 de Abr. de 2015
Yes, the spmd block has overhead which you can minimise by moving loops inside. Note that while labSend and labReceive work correctly with gpuArray data, they are not optimised for that (in the sense of some of the more advanced technologies that NVIDIA have for sending GPU data directly via MPI) - effectively the data has to be gathered back to the CPU before it can be sent.
Categorías
Más información sobre Parallel Computing Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!