Failing to free GPU memory on cleared/replaced/gathered variables: 2017a
4 views (last 30 days)
Show older comments
Hello all, I am running into an out of memory error on my GPU (8 GB, GTX 1080). I have drilled down to the code segment that keeps throwing the error, and it appears to be an issue with Matlab failing to free memory on the gpu after calculation. Specifically, this is occurring after an interp2 command.
I am attaching a MWE as a PDF. Long story short, this shows that after the interp2 command, a sizeable block of GPU memory never gets freed up even after all of the workspace variables on the GPU being cleared, gathered, or replaced. This is a major issue if the result of the interp2 operation is large enough that gather(gpuData) causes an out of memory error; there is no way to pull the data off of the GPU without resetting the GPU, which wipes the data.
Is this a 2017a issue? Any help would be appreciated.
0 Comments
Accepted Answer
Joss Knight
on 28 Jun 2018
It's difficult to say exactly what is going on here, however I'm fairly sure that it is the cublas context that is occupying memory on the first call. This is perfectly normal and doesn't constitute any kind of memory leak. You can run this computation repeatedly from this point on and the overall memory usage remains the same. I believe it's cublas because if I replace your function with a simple call to v.*v I don't see this behaviour; whereas if I call v*v (a cublas call) I do. I think cublas is pooling a lot of memory and kernels and this is not reported as free memory.
More Answers (0)
See Also
Categories
Find more on GPU Computing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!