Parpool threads killed when scaling up
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chern Hui Lee
am 29 Okt. 2021
Kommentiert: Chern Hui Lee
am 31 Okt. 2021
In my script, I have a big custom function in a loop, in each loop this function is called with different parameters. So I try to use parpool('threads') and parfeval to calculate the result ahead of time, and then just retrieve the result in each loop to speed up the total calculation. This is all good, until I increase the size of the matrix in my custom function.
I run Matlab using "matlab -nodisplay". When I increase the size of the matrix slowly, beyond a certain point, I would just see the following:
Killed
and Matlab is quit. How do I know what went wrong? Is the matrix too big and I run out of memory? I verified that the custom function itself runs fine with the big size of matrix.
My computer has 8 cores, when I run parpool('threads'), it gives me a pool of 8 workers. If it's a memory issue, can I reduce the number of workers? Because I do not think I need that many workers to achieve the speed, but I can't find a way to reduce the number of workers when using parpool('thread'). Or should I move to process-based parallel computing, instead of thread-based?
Thanks.
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 29 Okt. 2021
What operating system? If you're running on Linux, check if MATLAB got killed by the out of memory killer.
Weitere Antworten (1)
Walter Roberson
am 29 Okt. 2021
Unfortunately, R2020a's parpool('threads') and R2021b's backgroundPool() do not permit you to configure the number of threads to use, so running out of memory is a possibility.
4 Kommentare
Raymond Norris
am 30 Okt. 2021
Notice the following:
>> nt = maxNumCompThreads(2)
nt =
4
>> parpool("threads");
Starting parallel pool (parpool) ...
Connected to the parallel pool (number of workers: 2).
This shows I have 4 cores and that by calling maxNumCompThreads with2, parpool starts a thread-based pool of 2 workers. They caviat -- until you set maxNumCompThreads back to 4, all other code will also only use 2 threads. Then again, you could make the argument that's idea (if not actually setting it to 1), since the parallel pool may now be running on 2 cores. I wonder if a better internal algorhim would be something like
>> new = 3;
>> old = maxNumCompThreads(new);
>> pool = parpool("threads");
Starting parallel pool (parpool) ...
Connected to the parallel pool (number of workers: 3).
>> maxNumCompThreads(max(old-new,1))
This way MATLAB has at least 1 comp thread, but otherwise, the comp threads and the parpool theads equal the total number of cores seen.
Going back to the OP, a local process-based pool won't perform better than a thread-based pool. I emphasize local because certainly you could span a process-based pool across multiple nodes with MATLAB Parallel Server that has access to more memory, etc., whereas a thread-based pool is bound to a single node.
Secondly, I don't see how reducing the number of threads/processes will help. You're justing giving more work/memory to each process. As was seen, the best option is to get onto a machine with more memory.
Siehe auch
Kategorien
Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!