Using multiple GPUs in a parfor type of loop
1 次查看(过去 30 天)
显示 更早的评论
I am working on a machine learning problem where I am training my classifier using a GPU and the parallel computing toolbox. I want to do 10-fold cross-validation (basically train 10 different classifiers, completely independently of each other). I have access to a machine with two Tesla GPUs. Is there a straightforward way to to combine a parfor loop with two workers, each with their own GPU attached, to do this?
When I open the matlabpool can I just specify the two different GPU devices, one for each worker and then never have to bother with it again?
回答(1 个)
James Lebak
2013-4-5
In R2012b and later, in a matlabpool on a single machine with two GPUs, each worker will use a different GPU by default. You can see this by executing the following code:
matlabpool local 2
parfor ix = 1:10
gd=gpuDevice;
d(ix)=gd.Index;
end
The value of d will show you the index of the GPU on which each iteration was executed.
In earlier releases the workers all use device 1 by default, and you would have to set the device manually using spmd outside the parfor loop or (less optimally) inside each loop iteration.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!