Hello, So I am using GPU computing to vastly speed up some of my computations, but keep running into "out-of-memory" errors. I need to either predict when an operation will result in a GPU memory issue (so I can break up the problem further), or fix my code to avoid such issues. [Note, I am on a Titan-X w/ 12 GB onboard; part of the issue is to make sure my code won't crash on lighter power machines.
As such, I have a few questions:
(A) How do I estimate the GPU memory load of certain operations. e.g. I have two large [M,N,O] gpuArray's and I need to multiply them; the memory requirement seems to be more than just 3x the memory footprint of one of those matrices (each input, and one output). The same question applies to fft, abs, conj, and any other matrix operation I want to perform on the GPU.
I know I can check available memory using gpuDevice(). If I know how much memory an operation will require, I can predict if I will over-run.
———————————-
(B) When a function returns, does it automatically free the gpu memory allocated during its run? If it does, I don't understand what is eating away at my AvailableMemory; the variables in my workspace at the stage I crash come nowhere close to what is occupied on the card.
——————————
(C) Is there a way to find out what Matlab variables might still be on the card and their actual size? I have been using 'gather' to pull the variables down, and then 'whos' to estimate their size; however I assume there is not a one-to-one relationship on and off the card.
—————————–
(D) Without looping through current variables in the workspace and doing a class check, is there a fast way to pull all current variables off of the card, perform reset(gpuDevice) and then load them back on? [Probably not, I should really just write a function that does just that]
Thanks, -Dan
Best Answer