フィルターのクリア

parallel programming toolbox shutting down

114 ビュー (過去 30 日間)
Hossein
Hossein 2015 年 2 月 20 日
コメント済み: Xinqi Wei 2023 年 12 月 21 日
I have a matlab code that has a structure similar to the following
for i=1:10
Some code here
parfor j=1:10
cost(i,j)=feval(myfunction,SomeParameter);
end
end
This code takes a day to run because @myfunction is expensive to calculate. My issue is that once I run the code the parallel programming starts but after a while it becomes idle automatically. parallel pool is already on once it reaches "parfor" but it becomes idle after i=2! You can see it in the parallel computation status bar on the lower bottom corner (Im using 3 out 4 cores)
  2 件のコメント
Cristiano
Cristiano 2015 年 2 月 20 日
And what happens if you suppress the first loop? I.e., the first line is:
for i=1:1
Does it keep shutting down?
Hossein
Hossein 2015 年 2 月 21 日
Let me correct my question. The parpool does not shut down after i=2, it actually becomes idle. For i=1:1 it works fine but for the next time (i=3) it becomes idle.

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

回答 (3 件)

Edric Ellis
Edric Ellis 2015 年 2 月 23 日
You can disable the IdleTimeout behaviour of the parallel pool in one of 2 ways:
  1. Bring up the "parallel preferences" (available via the icon in the bottom-left corner of the MATLAB desktop) and uncheck the box marked "Shut down and delete parallel pool after it is idle for ...". This will then apply to all future pools.
  2. Explicitly disable the IdleTimeout for a given pool by calling something like
parpool(4, 'IdleTimeout', Inf)
  1 件のコメント
Dio
Dio 2018 年 8 月 6 日
Hi Edric, I don't think Mike's issue is related to IdleTimeout as it's not a time-related issue but iteration-related. I'm experiencing the same problem as him, where parallel processing goes Idle once my first iteration is finished (order of a few seconds, so not IdleTimeout-related) From the second iteration onwards, parallel is Idle. I'm using fmincon with the option 'UseParallel' set to true. Any idea why the optimisation becomes serial after the first iteration? Thanks.

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


Sardar Azari
Sardar Azari 2018 年 10 月 13 日
I have exactly the same issue as Dio. Did you find any solutions?
  2 件のコメント
Dio
Dio 2018 年 10 月 13 日
Yes, upgrading from v2016 to v2017 or v2018 fixed this for me.
Yantao Shen
Yantao Shen 2019 年 1 月 18 日
I have exactly the same problem for R2017b

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


Raimundas Steponavicius
Raimundas Steponavicius 2021 年 2 月 11 日
I have a similar problem too. I use fmincon for a large problem (nearly half a million variables), with the following options/settings:
options=optimoptions('fmincon','Algorithm','interior-point','Hessian','lbfgs','SubproblemAlgorithm','cg','InitBarrierParam',1,'InitTrustRegionRadius',sqrt(length(x0))*1e-3,...);
After every iteration the parallel pool goes idle for some time, and this idling time between the iterations is gradually increasing with iterations. I do not know why and how to deal with this.
I tried it on different versions of MATLAB (R2016b, R2018b, R2020a and R2020b), but the same problem persists.
Any answers as of why this is happening and how to fix this ?
  2 件のコメント
Somayeh G. Esfahani
Somayeh G. Esfahani 2023 年 3 月 1 日
編集済み: Somayeh G. Esfahani 2023 年 3 月 1 日
I did not have any problem with 2018a and setting 'UseParalell' to on, but other releases have made similar problem for me. My code runs well iin serial mode, but when paralell option is on it returns the following erorr:
Error using fcnvectorizer
Function to evaluate must be represented as a string scalar,
character vector, or function_handle object.
Error in makeState (line 69)
Score = fcnvectorizer(state.Population(initScoreProvided+2:end,:),FitnessFcn,1,...
Error in galincon (line 24)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 416)
[x,fval,exitFlag,output,population,scores] = galincon(FitnessFcn,nvars, ...
Error in main_ga_WT_no2nh4zeroatBC_11feb_matlab2022b (line 29)
[q,sse,exitflag,output,fin_popul,scores] = ga(fnc_GA,4,[],[],[],[],lb,ub,[],options);
Caused by:
Failure in user-supplied fitness function evaluation. GA
cannot continue.
I am using genetic algorithm, and I need to run in paralell to get to the next generations in a reasonable time frame. Unfortunately, this sounds like a bug in new versions of matlab.
Xinqi Wei
Xinqi Wei 2023 年 12 月 21 日
I also have this problem, it works well in R2023 a at begin, but I changed the paramaters in objective function, it shown same problem, Error using fcnvectorizer
Function to evaluate must be represented as a string scalar,
However, R2023 b version has fixed this problem in new Release.
I will try it.

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

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by