Memory issue with eig function and GPU Array

5 visualizaciones (últimos 30 días)
cyan
cyan el 3 de Jun. de 2019
Comentada: cyan el 4 de Jun. de 2019
I'm running an iterative simulations in MATLAB where in each iteration the eigenvalue and eigenvector are solved. The result will be applied in the next iteration. SInce the matrix size is quite large (at least 5000x5000 complex number), I'm using the GPU array to accelerate the computation. It allows me gain almost 2 to 3 times of the speed which is great.
However, the memory used by Matlab will continuously increase after each call to "eig" function with GPU array. This does not happen will CPU array. The increment of the memory also scales with the matrix size. And my computer will become out-of-memory in less than 100 iterations that is not practice at all. I have tried to clear every variables and functions possible but the problem persists.
Here is a simplied code to represent the problem:
% create input matrix
mSize = 1000;
runs = 10;
AC = rand(mSize, mSize, runs).*exp(1i*2*pi*rand(mSize, mSize, runs));
AG = gpuArray(AC);
% GPU calculation
mem_gpu = zeros(runs,1);
for idx = 1:runs
[VG_tmp, EG_tmp] = eig(AG(:,:,idx));
clear VG_tmp EG_tmp G;
clear eig;
wait(gpuDevice);
user = memory;
mem_gpu(idx)=user.MemUsedMATLAB;
end
% CPU calculation
mem_cpu = zeros(runs,1);
for idx = 1:runs
[VC_tmp, EC_tmp] = eig(AC(:,:,idx),'vector');
user = memory;
mem_cpu(idx)=user.MemUsedMATLAB;
end
% plot and compare
figure(1);clf;
plot(1:runs,[mem_cpu,mem_gpu],'o-');
As you can see from the code, I have cleared all the gpuarrays as well as the eig function. The figure below is the comparison of the RAM usage after 10 iteration. The red curve is from GPU and the the blue curve is from CPU.
I am using Matlab 2017b and GPU is 'GeForce GTX 1080 Ti'.
The only way to clear this invisible memory is by restarting the Matlab, which I can not afford in this case.
Is it a bug in the eig implementation? Any idea how to fix it? Thank you.

Respuesta aceptada

Edric Ellis
Edric Ellis el 4 de Jun. de 2019
Using your reproduction steps, I was able to see the problem using R2017b, but this appears to be fixed in R2019a - so please try that version if you are able to.
  1 comentario
cyan
cyan el 4 de Jun. de 2019
Than you very much. The latest version fix the issue.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre GPU Computing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by