Preserving gpuArray data across Multiple GPUs

조회 수: 14 (최근 30일)
Bracy Elton
Bracy Elton 2015년 9월 4일
답변: Edric Ellis 2015년 9월 7일
We have 16 GPUs on a single compute node. I'd like to create data on each GPU and have it preserved across uses of gpuDevice (to switch from one GPU to another). From experimentation, it appears that data is destroyed when switching from one GPU to another.
I'd like to do something like:
Initialize all output and work arrays on all GPUs.
Do other initialization work.
Iterate over streaming input data:
Have all GPUs work on the current group of data (using a parfor), generating its own output.
Do a reduction operation across GPUs to gather the results from all of them to one place on the CPU.
end
I don't see how to do this presently when using gpuArray, which is what I would prefer to use. This, for example, does not work:
gpuDevice(1);
A = rand(100,100,'gpuArray');
gpuDevice(2);
existsOnGPU(A)
B = rand(100,100,'gpuArray');
existsOnGPU(A)
existsOnGPU(B)
gpuDevice(1);
existsOnGPU(A)
existsOnGPU(B)
gpuDevice(2);
existsOnGPU(A)
existsOnGPU(B)
existsOnGPU returns 0 when switching from one GPU to another for data that we previously on that GPU.
Is there a way to have gpuArray data preserved in a GPU when attention is (temporarily) focused on a different GPU?
Please advise.
Thanks so much.
Cheers. --Bracy

답변 (2개)

Bracy Elton
Bracy Elton 2015년 9월 4일
Added gpuArray tag

Edric Ellis
Edric Ellis 2015년 9월 7일
Each MATLAB process can access only a single GPU at a time. The only way to preserve data when switching GPU devices is to call gather to bring the data to the CPU.
However, I suspect this is not really what you want to do - if you're trying to take advantage of all GPUs simultaneously, you need to open a parallel pool, and have each worker use a different GPU device. There's a detailed blog article showing how to achieve that.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by