Memory increases on GPU while performing modification inplace
Ältere Kommentare anzeigen
When I allocate squeeze a 3D array to output a 2D array, my memory is increasing while I think I performing the modification inplace. That way I would expect that since the number of elements in the array does not incease, the memory used on the GPU does not increase.
However, I see something different in the task manager. What is going on?
- MATLAB Version: 9.8.0.1538580 (R2020a) Update 6
- Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 18363)
- NVidia GeForce RTX 3090
data = zeros(5632000, 128, 2, 'int16');
testSO(data);
function testSO(RF)
whos RF % int16 2.75 GB
size(RF); % 5632000x128x2
% GPU memory at beginning 1.2 GB
RF = gpuArray(RF); % 3.9 GB
RF = squeezingSuperFrames(RF); % 6.6 GB
end
function RF = squeezingSuperFrames(RF)
% concatenate pages of 3D array to create tall RF array
RF = reshape(permute(RF, [1 3 2]), [], size(RF, 2), 1);
end

Antworten (2)
Joss Knight
am 10 Okt. 2021
0 Stimmen
MATLAB cannot perform this operation in place because data is a workspace variable. MATLAB has no way of knowing there won't be an error or user interrupt (Ctrl-C) during execution, so it takes a copy of data to ensure your workspace would not be corrupted.
3 Kommentare
rinkert
am 10 Okt. 2021
Joss Knight
am 11 Okt. 2021
Good point, I wasn't paying proper attention to when you were moving data to the GPU. As Matt points out, your culprit is permute.
MATLAB may be still holding onto the memory, but only because it is pooled, it is not preventing its use. This is a performance optimization. You can see that this memory is available for use by other MATLAB variables and operations by inspecting the AvailableMemory property in the output of gpuDevice.
rinkert
am 12 Okt. 2021
Kategorien
Mehr zu Parallel and Cloud finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!