MATLAB Answers

Gather cell array from GPU to CPU

15 views (last 30 days)
Ted
Ted on 1 Nov 2019
Answered: Joss Knight on 1 Nov 2019
Hello,
I have a cell array (let's call it 'A_gpu') where each cell contains a matrix which has been allocated on GPU device. I want to migrate the matrices onto CPU memory and still organize them in the same cell array format as before.
I tried
A_cpu = gather(A_gpu);
Then, I check the allocation of A_cpu. Unfortunetly, they are still on the GPU. Task failed.
The intuitive solution will be gathering the matrix at each cell individually and loop over the cells. I am wondering whether there is a short function, maybe a Matlab built-in function that I may not be aware of, that can help me relocate the cell array from GPU to CPU.
Thank you,
Ted

  0 Comments

Sign in to comment.

Accepted Answer

Joss Knight
Joss Knight on 1 Nov 2019
A_cpu = cellfun(@gather, A_gpu, 'UniformOutput', false);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by