Parfor loop just hangs, CPU usage goes to zero

14 visualizaciones (últimos 30 días)
JohnDapper
JohnDapper el 14 de Mzo. de 2016
Respondida: Tianzong Wang el 27 de Oct. de 2022
Hi all. Here is a sample code of what I am attempting to run.
parfor i = 1:num
answer(:,i) = someFunction(someData(:,i));
end
Key information: "someFunction" is a C++ mex file. "someData" is a memmapfile (memmapfilename.data) because it is too large to be loaded onto each worker
Oddly, the parfor loop just hangs, the CPU usage goes to zero, and when I CTRL+C, here is what I get:
Operation terminated by user during distcomp.remoteparfor/getCompleteIntervals (line
127)
In parallel_function>distributed_execution (line 820)
[tags, out] = P.getCompleteIntervals(chunkSize);
In parallel_function (line 587)
R = distributed_execution(...
This isn't an issue if I replace the "parfor" with a simple "for" - everything works fine. What seems to happen is that some of the workers become unresponsive. After the above issue is encountered, even running a simple command such as
pctRunOnAll 1+1
will return "2" on only some, but not all, workers.
Any help would be great. A fresh re-installation did not help. Validation for "parpool" passed.
  5 comentarios
John Tencer
John Tencer el 3 de Abr. de 2018
I'm observing this behavior with 2017b.
David Saidman
David Saidman el 14 de En. de 2020
Did anybody get any success with this? I'm having exact same 2017b, definitely no keyboard statement.
If I wait a bit, it ends up running but on a single CPU (event tho I have 18 in my pool on a cpu with 20 physical and 40 logical cores, about 10gb spare memory in performance monitor).

Iniciar sesión para comentar.

Respuestas (7)

Dave Behera
Dave Behera el 24 de Mzo. de 2016
It seems that there is a deadlock when the workers are trying to the access the file using the same object (that you got from memmapfile). Due to that, the progress is getting stalled with zero CPU usage and no abort message.
Can you try creating a separate memmapfile object within each parfor iteration and passing it to the someFunction function? This may make the file access thread-safe.
Also, could you try the same workflow with spmd?
  8 comentarios
Hakon Haugnes
Hakon Haugnes el 16 de Sept. de 2019
I have the same problem on R2018a
Arabarra
Arabarra el 11 de En. de 2021
Same problem here. In my case it is not reproductible, sometimes it will work, sometimes not. No deadlocks or anything suspicious in the code.

Iniciar sesión para comentar.


arvid Martens
arvid Martens el 9 de En. de 2018
I noticed that the problem started to occur after I updated the drivers of the GPUs that are being used during the calculations. Rolling back the drivers resolved the problem. However, new GPU hardware is on its way, as the current ones are pretty old. So I hope the problem is resolved by then.
Is there a way to throw an error when this stalling occurs? I could write an error handling to reduce the time lost by this stalling.

Andrea Stevanato
Andrea Stevanato el 13 de Jul. de 2018
I have the same error with matlab 2018a.

Sanjay Manohar
Sanjay Manohar el 3 de Jun. de 2019
Editada: Sanjay Manohar el 3 de Jun. de 2019
I was having the same parfor problem, until I noticed I had a "keyboard" instruction in my code.

DeepSea
DeepSea el 15 de Ag. de 2021
I've been stucked in this problem for couples of weeks, and fixed it by removing "continue" in an if-judgement and a for-loop.
for CondA
...
if CondB
continue; % Avoid using "continue"
end
...
end

Aditya Shukla
Aditya Shukla el 23 de Oct. de 2021
I suddenly got this problem since yesterday, before which all the code ran nicely. I really do not know why this happened. it is so annoying. Any one found a solution?

Tianzong Wang
Tianzong Wang el 27 de Oct. de 2022
Same here, most cores are not working. Any suggestions? And what is the JCEF?

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by