Problem with parfor with two variables

Hi,
My code below is executed normally without the parfor command i.e with the for command.
Moreover when I reduce the numbre of cores to 4 in parfor command, the code run normally, it will be displayed on the screen ('Time to calculate the (i,j)th couple is ....) but if I use all the 32 cores I didn't see anything in my screen after 24h of the execute my code.
Can you help me this is urgent.
Thank you for our help.
%% My code
Y_1 =zeros(N,numel(alpha),numel(beta));
Y_2 =zeros(N,numel(alpha),numel(beta));
parfor k =1:numel(alpha)*numel(beta)
Tm=tic;
[i,j]=ind2sub([numel(alpha),numel(beta)],k);
[Y_1(:,k),Y_2(:,k)] = My_Fun(alpha(i),beta(j),..);
fprintf('Time to calculate the (%d,%d)th couple is %f \n',i,j,toc(Tm))
end

댓글 수: 4

Rik
Rik 2021년 11월 23일
You could try creating files instead. That way you bypass any restrictions from the command window.
Also, you probably want f instead of d in your format specification. The time is not likely to be an integer.
B.E.
B.E. 2021년 11월 23일
Thanks, I'm using it's a typo
Edric Ellis
Edric Ellis 2021년 11월 24일
I would check the memory usage on your system. It may be that when using 32 cores, you're overwhelming the system memory and things are running extremely slowly.
B.E.
B.E. 2021년 11월 24일
Thanks Edric,
The size of the calculated array exceeds the size of the memory. I reduce the number of cores to 12, it works, but the execution time is great about 50h.
Thank you again.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2021년 11월 24일
편집: Matt J 2021년 11월 24일

0 개 추천

Do you need to see the toc output in real time? If not, just save it until later:
%% My code
Y_1 =nan(N,numel(alpha),numel(beta));
Y_2 =nan(N,numel(alpha),numel(beta));
Times=nan(numel(alpha), numel(beta));
parfor k =1:numel(alpha)*numel(beta)
Tm=tic;
[i,j]=ind2sub([numel(alpha),numel(beta)],k);
[Y_1(:,k),Y_2(:,k)] = My_Fun(alpha(i),beta(j),..);
Times(k)=toc(Tm);
end

카테고리

도움말 센터File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

질문:

2021년 11월 23일

댓글:

2021년 11월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by