How to set a background pool to process-based instead of thread-based
27 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to read and write files in the background of my matlab app. However, when I run the function that I want executed in the background
pool = backgroundPool;
f = parfevalOnAll(pool, @fetchAndPrepareData,0,filePaths);
I get the error message
f(1).Error{1}
ans =
ParallelException with properties:
identifier: 'parallel:threadpool:DisallowedBuiltin'
message: 'Use of function fopen is not supported on a thread-based worker.'
cause: {}
remotecause: {[1×1 MException]}
stack: [3×1 struct]
Correction: []
I've done some small work previously using parpool where you can use parpool('threads') or parpool('local') to switch, but I can't seem to find a similar way of achieving this using a backgorund pool.
If people know of a different way to read/write files in the background I am also open for other ideas, but I really want it done in the background since the files takes a very long time to load and the user needs to work on each file for qutie some time so I want the reduce wait time for the user to a minimum by reading the next file while the user is performing the work.
0 件のコメント
採用された回答
Edric Ellis
2022 年 7 月 14 日
Unfortunately, as you have seen fopen is not yet supported on thread-based pools such as backgroundPool. There is no way to configure which type of pool is used for backgroundPool, so for now, you must continue to use parpool("local") to create a process-based pool. You can use this just like backgroundPool.
(Of course, one advantage backgroundPool has over parpool("local") is that it is available with MATLAB without requiring Parallel Computing Toolbox. Unfortunately, for now, if you wish to allow things to work without PCT, you'll need to do a little extra work to avoid using parfeval here)
0 件のコメント
その他の回答 (1 件)
Jixiong Su
2023 年 11 月 25 日
You can use
pool=parpool('Processes')
f = parfeval(pool, @fetchAndPrepareData,0,filePaths);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Parallel Computing Fundamentals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!