Matlab image processing example
The code used in this example is modified slightly from an example of processing spectra data that is included as an example in the Matlab Bioinformatics toolbox; see Batch Processing of Spectra Using Sequential and Parallel Computing for additional details on the code.
Example files on ARC clusters can be found in /sw/examples/matlab/ovarian
, where there will be a .m
file and a .sbat
file for each type of cluster profile, for example, spectral_local.m
and spectral_local.sbat
which illustrate using the local profile.
When using the local
profile, your job script should request
#### Note that for Matlab, local profile, use cpus-per-task to set #### multiple processors, NOT --tasks-per-node #SBATCH --nodes=1 #SBATCH --tasks-per-node=1 #SBATCH --cpus-per-task=4
Whereas for the current
profile, your job script should request
#### Note that for Matlab, current profile, use tasks-per-node to set #### multiple processors, NOT --cpus-per-task #SBATCH --nodes=2 #SBATCH --tasks-per-node=2 #SBATCH --cpus-per-task=1
For the local profile, the environment variable SLURM_NPROCS
will contain the number of processors that the job has assigned, and you can use that in your MATLAB script. The following code will set N
to 4 if the SLURM_NPROCS
variable does not exist, so your `.m` script does not need to be changed to run outside of a job.
%%%% For use with the local profile %%%% You should start one worker per task if isempty(getenv('SLURM_NPROCS')) N = 4; else N = str2num(getenv('SLURM_NPROCS')); end
For the current profile, the environment variable SLURM_NTASKS
will contain the number of processors that the job has assigned for each worker, and you can use that in your MATLAB script. The following code will set N
to 4 if the SLURM_NTASKS
variable does not exist, so your `.m` script does not need to be changed to run outside of a job.
%%%% For use with the current profile %%%% You should start one worker per task if isempty(getenv('SLURM_NTASKS')) N = 4; else N = str2num(getenv('SLURM_NTASKS')); end