gpuArray and memory management
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have a loop in which I create a number of gpuArrays. To keep within memory limits I clear some gpuArrays with intermediate results. In Matlab R2011b everything was cleared nicely, but with R2012a the loop crashes with an out of memory exception (running the exact same code). I understand that I cannot completely trust the FreeMemory reported by gpuDevice, although I see that memory is freed in R2011b when in R2012a it is not. Is there some way to force R2012a to release the memory (without a reset)?
Thanks!
2 Commenti
Edric Ellis
il 8 Mag 2012
It sounds like you're probably being hit by GPU memory fragmentation. Do you have any reproduction steps you could post?
Risposte (1)
Ben Tordoff
il 8 Mag 2012
Hi Gunnar,
this is more a work-around than an answer, but try inserting a "wait(gpu)" after freeing the memory. For example:
gpu = gpuDevice();
bigData = parallel.gpu.GPUArray.rand(2000);
% do lots of computations
clear bigData;
wait(gpu);
In R2012a and above the GPU might still be running when you get to the "clear" command so it may need to hold onto the memory. Using "wait" to ensure all computations have completed allows the memory to be released safely.
However, this shouldn't be necessary. If memory runs low, MATLAB should wait and free up some memory automatically. Could you post a snippet of code that shows how to hit the problem so that I can see why this isn't happening for you? In particular, which function runs out of memory - is it a creation function (zeros, ones, rand etc) or an operation (fft, multiply etc)?
Thanks
Ben
Vedere anche
Categorie
Scopri di più su GPU Computing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!