By the way, if in this function I have three spmd block to run under same workers, can I just attach the folders only once at the lines after parpool and before the first spmd block?
For addAttachedFiles(myPool,'mydir'), how to add the Subfolders of 'mydir' recursively to the search path of worker?
4 ビュー (過去 30 日間)
古いコメントを表示
In the client I opened several workers by MDSC with MJS cluster "MyMJScluster" using multiple computers as node PC.
parpool('MyMJScluster')
Because the node PC does not have the necessary code to execute the spmd block, I need to attach all code files under several folders to them.
poolobj = gcp('nocreate')
addAttachedFiles(poolobj,{'D:\code\myCodeFolder1', 'E:\codeMatlab\myCodeFolder2',})
Then I run a function which has a spmd block.
spmd
…% code that use all files in {'D:\code\myCodeFolder1', 'E:\codeMatlab\myCodeFolder2',}
End
These folders not only has .m file, .p file and .mex file, but also has other files such as .txt, .pzfx , .mat, .exe, .dll that need to be accessed in worker by using “which” to find the local path and then run or read them. Most of all the above files are located in subfolders and even sub-sub-sub folders.
The problem is that for addAttachedFiles, although those entries listed in the addAttachedFiles are added to the top of the command search path in the worker session, subfolders of the entries are not added to the path, even though they are included in the folder structure of workwer. This cause the problem that worker cannot find those files automatically.
Is there a way to add the paths recursively for these folders to Matlab search path on the worker?
Thanks.
採用された回答
Walter Roberson
2018 年 9 月 11 日
genpath() and split at the : characters to get the cell array to attach.
regexp(genpath(FOLDER), ':', 'split')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Parallel Server についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!