how to use matlabpool and multiple GPUs simultaneously?

4 次查看(过去 30 天)
Hi, everyone. The matlab I am using is of version 2010b with parallel computing toolbox. And the machine on which the matlab is installed has 8 CPUs and 3 GPUs. When I use only for loop, I could access one GPU to conduct computation. Now, I'm wondering how to use parfor (e.g.,matlabpool(3)) together with 3 GPUs. That is to say, each CPU can access one GPU to conduct computation.
It's mentioned on the internet that Jacket is the only software that supports multiple GPUs for Matlabpool. I'm wondering if that is true.
I really want to know how to get the target by using matlab with parallel computing toolbox only. Your answer will be appreciated very much.
Best wishes and Merry Christmas,
Qian

回答(2 个)

Jason Ross
Jason Ross 2011-12-22
You can use labIndex as a means to connect the lab to one GPU. Do this inside a smpd block and you can control what goes to each GPU. The spmd statement lets you define a block of code to run simultaneously on multiple labs.
e.g.
matlabpool open 3
spmd
labindex
end

Friedrich
Friedrich 2011-12-22
Hi,
normally one uses the gpuDevice command to active/use a specific GPU device. I am not sure if this will work but I would try something like:
matlabpool open 3
parfor i=1:3
gpuDevice(i)
%gpu stuff here
end
This will open 3 workers and each worker will activate a different GPU for the computation. I can't test this since I don't have multiple GPU's so I am not 100% sure if this will work.
In addition see this thread for how to access the GPU from a worker

类别

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