currentProject() function in Parallel Computing Toolbox

4 vues (au cours des 30 derniers jours)
Isaac De La Cruz
Isaac De La Cruz le 14 Fév 2023
Commenté : Isaac De La Cruz le 15 Fév 2023
I have a workflow that uses the MATLAB project functions to retrieve information from the MATLAB project. I use currentProject() to get the matlab.project.Project object.
I am trying to run this workflow using the Parallel Computing Toolbox, but seems that the MATLAB project is not available in the MATLAB workers.
Tested it using this code:
Starting parallel pool (parpool) using the 'Processes' profile ... Connected to the parallel pool (number of workers: 2).
Error detected on workers 1 2.

Caused by:
Error using currentProject
No project is currently loaded.
Does the MATLAB project gets transferred into the MATLAB workers, or only the MATLAB path?
Any workaround about how can I pull the Project Reference information in a distributed environment?
Thanks in advance!

Réponse acceptée

Sean de Wolski
Sean de Wolski le 14 Fév 2023
You can open the project on all workers before the loop with parfevalOnAll.
rf = currentProject().RootFolder
parfevalOnAll(@()openProject(rf), 0)
parfor ii = 1:4
  1 commentaire
Isaac De La Cruz
Isaac De La Cruz le 15 Fév 2023
Thanks @Sean de Wolski! This solution works.
Unfortunately for me, the MATLAB projects has a lot of overhead during startup, so I decided to take another approach of storing the information from the MATLAB project before distribution.

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Project Management dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by