- If you have multiple right-hand-sides (b) you should solve for them all at once by concatenating them into a single b matrix.
- If you have multiple system matrices (A) you could use pagemldivide.
- Use the CPU since it's faster anyway
Memory leak occurring when repeatedly performing matrix left division on GPU
6 次查看(过去 30 天)
显示 更早的评论
Im working on a project that at its core relies on peforming many matrix left division operations in a regression problem. In order improve the speed of the program I have been attempting to get this matrix left division to run on the GPU. However whenever I peform this operation my local memory begins to rapidly fill until the system runs out of memory and matlab crashes. The GPUs (NVIDIA GeForce RTX 3060 Laptop GPU) memory however is unaffected. The code that I'm trying to run is effectively as follows (this code causes memory leaks when run on my system):
A=gpuArray(rand(10000,12));
b=gpuArray(rand(10000,1));
for l=1:10000000000000
x=A\b;
end
It should also be noted that the GPU version of my code runs significantly slower than the CPU version.
Any help with this issue would be appreciated, thank you.
0 个评论
采纳的回答
Joss Knight
2024-5-19
Thank you very much for reporting this. This appears to be a bug in MATLAB's gpuArray support for overdetermined solves. For now you should replace your calls to mldivide with the equivalent use of qr:
[Q,R] = qr(A);
x = R\(Q'*b);
Without knowing exactly why you are calling mldivide repeatedly I can't be sure of other advice, but other strategies might be:
On a laptop GPU I am not surprised if the GPU is not faster than the CPU for double precision, especially when you only have a single right-hand-side. If accuracy is not a big issue for you, you could try solving the problem in single precision instead of double. In double your mobile 3060 GPU is 64x slower than in single.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!