Click for detailed status
Matlab
MATLAB (Matrix Laboratory) is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks.
MATLAB on Euler¶
On Euler the following versions are available via modules:
| Version | Module command |
|---|---|
| R2023b | module load matlab/R2023b |
| R2024a | module load matlab/R2024a |
Documentation¶
https://www.mathworks.com/help/matlab/index.html
License¶
ETH has a MATLAB site license for the base license. For some toolboxes, there is only a limited number of licenses available at ETH.
Parallel computing with MATLAB products¶
MATLAB's Parallel Computing Toolbox (PCT) lets you run suitably-written programs in parallel or as a set of independent jobs. Several cores calculate different parts of a problem, possibly at the same time, to reduce the total time-to-solution.
Set up MATLAB to use SLURM local parpool¶
One-time preparation: Before using the SLURM job pool for the first time, you need to import a cluster profile. for that, start MATLAB and then call configCluster. For each cluster, configCluster only needs to be called once per version of MATLAB.
Importing cluster profile
Importing a cluster profile more than once per version will reset your cluster profile back to default settings and erase any saved modifications to the profile.
Use a local parpool¶
When you use the local parpool, you submit a multi-core job to SLURM. MATLAB will run additional worker processes within your multi-core job to process the parallel part of your program.
Example (simulation.m):
squares = zeros(100,1);
pool = parpool("threads", 4);
parfor i = 1:100
squares(i) = i^2;
end
disp(squares)
pool.delete()
sbatch --ntasks=1 --cpus-per-task=4 --time=1:00:00 --mem-per-cpu=2g --wrap="matlab -nodisplay -singleCompThread -r simulation"
You must not use the -nojvm MATLAB argument but you should include the -singleCompThread MATLAB argument. MATLAB is quite memory-hungry, so request at least 2 GB of memory per core as shown above.
!!! info 'Maximum number of cores for a local parpool' The largest Euler nodes have 192 cores, therefore local parpools are limited to 192 cores
Slurm parpool¶
When you use the SLURM parpool, you submit a single-core job to Slurm. MATLAB will submit an additional parallel job to run the MATLAB workers to process the parallel part of your program
Number of cores
Currently Slurm parpools with a smaler number of cores work well, while Slurm parpools with 100 or more cores fail due to an error that is related to the limit for the maximum number of processes.
Example (simulation.m):
squares = zeros(10,1);
batch_job = parcluster;
pool = parpool(batch_job, 4);
parfor i = 1:10
squares(i) = i^2;
end
disp(squares)
pool.delete()
sbatch -n 1 --time=120:00:00 --mem-per-cpu=2g --wrap="matlab -nodisplay -singleCompThread -r simulation"
Runtime limit for the master job
The master job is assumed to not need much CPU power; however, it may need to run for a long time since it needs to wait for the parallel pool job to start and run.