Multiple GPU's used in parallel.
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm using R2014b and I'm fortunate enough to be in an environment where I have multiple GPU's available.
I have code that uses parfor's to divide the code up over multiple workers. It works fine.
I have code that uses a single GPU by using gpuArray to load the input variables, native Matlab routines to do the processing and gather to retrieve the output. It works fine.
I am familiar with Loren's blog which seems to be a cookbook for my next step, using multiple GPU's. http://blogs.mathworks.com/loren/2013/06/24/running-monte-carlo-simulations-on-multiple-gpus/
The thing is she doesn't push any old data out onto the GPU's and is using arrayfun instead of gpuArray and native matlab.
stay with me here.... Computation within my parfor loop uses several variables from earlier in the code. These variables are all input which will not be changed within the parfor. The code executes fine in that state. When I set my number of workers to 1 the code works fine.
When I start trying to use a single GPU (with one worker) and try to load data into the GPU I hit a snag.
workers = 1;
Zc=2.25;
parfor www = 1:workers;
ftemp=zeros(nx,ny);
ftemp = gpuArray(ftemp);
Zc = gpuArray(Zc);
...
loading Zc onto the GPU gives me the following error.
Error using testz (line 513)
An UndefinedFunction error was thrown on the workers for 'Zc'. This might be because the file containing 'Zc' is
not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached.
See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
Caused by:
Undefined function or variable 'Zc'.
Going back to Loren's blog it seems the best solution may be to refactor my code to use arrayfun instead of gpuarray, but I hate to get into that without really understanding the root of my problem and why my current approach is exploding.
Advice is welcome. Other than the blog referenced above, there just isn't a lot of current info about using multiple GPUs. Thanks for reading.
5 commentaires
Joss Knight
le 28 Mai 2015
David, you won't be able to allocate GPU memory in one loop that you can access in another, especially when you have multiple GPUs. The host machine owns all arrays outside the loops and any gpuArrays must be stored on its GPU - and the mechanism for passing data back and forth to the workers uses CPU memory so you're gaining nothing. Keep your data in CPU memory and send it to the device inside your loops for your computations.
Réponses (0)
Voir également
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!