parfor 内存累计不释放

42 ビュー (過去 30 日間)
克
2023 年 7 月 22 日
コメント済み: 2023 年 8 月 9 日
这样的parfor里面存在什么问题吗?
运行的服务器512G内存 10核运算仍然会满内存
n = 1; %as an input is a content in parfor (常数)
ebler = 0;
for k = 1:loopout % loopout = 100000
C = 0; V = 0;
Blockerror = zeros(loopin,,1);
parfor j = 1:loopin %loopin = 1000
[C V] = function1();%renturn c and v
Blockerror(j,,1) = 1-qfunc(sqrt(n)*C./sqrt(V));
end
bler = bler + sum(Blockerror);%sum Blockerror (累加Blockerror)
clear Blockerror C V;
end

回答 (1 件)

Shushant
Shushant 2023 年 8 月 9 日
Hi ,
I understand that when you execute your code your server memory is running out of space. This issue is because you are using a "parfor" loop inside a for loop, due to this the amount of data transferred will be much greater and you will also not notice any major computational benefit when compared to nested-for loops. This happens because each of the multiple “parfor” executions incurs an overhead.
To solve this issue run the outer loop in parallel instead of the inner loop, this will ensure that the overhead incurs only once. For more information on the same, kindly refer to the following documentation -
I hope this provides you with the required information regarding your query.
Thank you,
Shushant
  1 件のコメント
克
2023 年 8 月 9 日
Thanks for your answer. I find my problem and solved it by using outer loop "parfor" and changing the huge array to small array, then sum it. Thanks again!

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

カテゴリ

Help Center および File Exchange循环及条件语句 についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!