I have problem with clear GPU memory
64 views (last 30 days)
After executing this code, the GPU memory is use by 2 GB. Only the D matrix in GPU memory...
clear E F C A B
However, if I execute this code.
There we see D matrix (same size) in GPU memory, but now it only use 1 GB of GPU memory. Why is there a difference? and how to clear the memory in the first variant?
Joss Knight on 2 Nov 2020
MATLAB does not clear all GPU memory unless all variables are released because allocating memory is a performance bottleneck. So MATLAB instead pools memory for later allocations.
To force the GPU to release all memory, you can call reset(gpuDevice).