フィルターのクリア

Memory leak occurring when repeatedly performing matrix left division on GPU

8 ビュー (過去 30 日間)
Harry
Harry 2024 年 5 月 16 日
コメント済み: Harry 2024 年 5 月 20 日
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.

採用された回答

Joss Knight
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:
  • 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
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.
  1 件のコメント
Harry
Harry 2024 年 5 月 20 日
Thank you very much this solved the issue, thank you also for the advice in improving program speed.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by