Gather cell array from GPU to CPU

조회 수: 11 (최근 30일)
Ted
Ted 2019년 11월 1일
답변: Joss Knight 2019년 11월 1일
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

채택된 답변

Joss Knight
Joss Knight 2019년 11월 1일
A_cpu = cellfun(@gather, A_gpu, 'UniformOutput', false);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by