# Difference between revisions of "MATLAB/Parallel"

(Adds Troubleshooting section) |
(Clarifies how many cores an Euler node has.) |
||

Line 10: | Line 10: | ||

when done, close the pool: | when done, close the pool: | ||

matlabpool close; | matlabpool close; | ||

− | Note that the ''local'' matlabpool is limited to 12 cores in releases up to R2016a (8.7/9.0). From release R2016b (9.1) on, you can use all the cores of Euler nodes. | + | Note that the ''local'' matlabpool is limited to 12 cores in releases up to R2016a (8.7/9.0). From release R2016b (9.1) on, you can use all the cores of Euler nodes (effectively 24). |

=== Submit a Parallel Job === | === Submit a Parallel Job === |

## Revision as of 15:15, 14 February 2017

MATLAB's Parallel Computing Toolbox can be used to run suitably-written programs in parallel—on multiple cores at once. For this the newest version of MATLAB that is available is recommended.

For suitable MATLAB programs (such as those containing `parfor` loops), using the Parallel Computing Toolbox requires two steps

- opening a
*local*matlabpool and - telling Euler's bsub scheduler to request multiple cores.

### Use the *local* matlabpool

Use the *local* matlabpool in your MATLAB program and specify the number of cores (e.g., 4):

matlabpool('local', 4);

when done, close the pool:

matlabpool close;

Note that the *local* matlabpool is limited to 12 cores in releases up to R2016a (8.7/9.0). From release R2016b (9.1) on, you can use all the cores of Euler nodes (effectively 24).

### Submit a Parallel Job

Pass the number of cores (e.g., 4) to bsub's `-n` argument:

bsub -n 4 -W "1:00" matlab -nodisplay -singleCompThread -r simulation

Note that you must *not* use the `-nojvm` argument but you *should* include the `-singleCompThread` argument.

### Troubleshooting Parallel Jobs

Using parallel pools often results in hard-to-diagnose errors. Many of these errors are related to running several pools at the same time, which is not what MATLAB expects. If you encounter persistent problems starting pools, try to perform one of these commands. Before running them, make sure that you do not have a MATLAB processes running.

- Remove the
`matlab_metadat.mat`file in your current working directory. - Remove the
`$HOME/.matlab/local_cluster_jobs`directory. - Remove the entire
`$HOME/.matlab`directory.**Warning**: Your MATLAB settings on Euler will be lost.