MATLAB Answers

parallel programming toolbox shutting down

68 views (last 30 days)
Hossein
Hossein on 20 Feb 2015
Commented: Yantao Shen on 18 Jan 2019
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 Comments

Cristiano
Cristiano on 20 Feb 2015
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 on 21 Feb 2015
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.

Sign in to comment.

Answers (2)

Edric Ellis
Edric Ellis on 23 Feb 2015
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 Comment

Dio
Dio on 6 Aug 2018
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.

Sign in to comment.


Sardar Azari
Sardar Azari on 13 Oct 2018
I have exactly the same issue as Dio. Did you find any solutions?

  2 Comments

Dio
Dio on 13 Oct 2018
Yes, upgrading from v2016 to v2017 or v2018 fixed this for me.
Yantao Shen
Yantao Shen on 18 Jan 2019
I have exactly the same problem for R2017b

Sign in to comment.

Sign in to answer this question.