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?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
raym
am 11 Sep. 2018
Beantwortet: Walter Roberson
am 11 Sep. 2018
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.
Akzeptierte Antwort
Walter Roberson
am 11 Sep. 2018
genpath() and split at the : characters to get the cell array to attach.
regexp(genpath(FOLDER), ':', 'split')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Search Path 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!