MATLAB: How to start the MDCE in MATLAB 7.5 (R2007b) or later versions

howtoMATLAB Parallel Servermdcemdcsstart

Where can I find the documentation for starting workers using the MATLAB Distributed Computing Engine?

Best Answer

Below is a sample M-script for starting up 4 workers on a local machine with the MATLAB Distributed Computing Engine installed.
%%This document assumes you have successfully installed the MDCE Toolbox
%%Install the MDCE
cd([matlabroot '\toolbox\distcomp\bin'] or (matlabroot '\toolbox\parallel\bin')(R2019b & later)
!mdce install
%%Start the MDCE
!mdce start
%%Start the MDCE and prepare for Distributed processing
% If you would like to see the status of the workers as they run, please
% set this to true
STATUS = true;
% Start a Job Manager
% -name the name of the Job Manager
!startjobmanager -name my_jobmanager
% Start 4 workers using the previously defined Job Manager
% -name name of the worker
% -jobmanager name of the Job Manager
% -jobmanagerhost name of the machine the manager is running on
!startworker -name worker_1 -jobmanager my_jobmanager -jobmanagerhost localhost
!startworker -name worker_2 -jobmanager my_jobmanager -jobmanagerhost localhost
!startworker -name worker_3 -jobmanager my_jobmanager -jobmanagerhost localhost
!startworker -name worker_4 -jobmanager my_jobmanager -jobmanagerhost localhost
if STATUS
% Output the status of the workers as they are running
!nodestatus
end
%%Run your code
% After the above has been started, you can run your code
% When you are done running your code execute the below cells of code
% to cleanly shut down the Workers, Job Manager and MDCE
%%Stop all the Workers, Job Manager and the MDCE
cd([matlabroot '\toolbox\distcomp\bin'])
% Stop the 4 workers previously started
!stopworker -name worker_1 -jobmanager my_jobmanager
!stopworker -name worker_2 -jobmanager my_jobmanager
!stopworker -name worker_3 -jobmanager my_jobmanager
!stopworker -name worker_4 -jobmanager my_jobmanager
% Stop the Job Manager
!stopjobmanager -name my_jobmanager
%%Stop the MDCE
!mdce stop
%%Uninstall the MDCE
!mdce uninstall