Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revisionBoth sides next revision | ||
doku:matlab [2020/01/16 12:46] – [Run Matlab Task from command line] ir | doku:matlab [2022/12/21 07:18] – amelic | ||
---|---|---|---|
Line 16: | Line 16: | ||
- | ===== Batch Matlab job on VSC-3 ===== | ||
- | In order to be able to use matlab, you have to load the program with the ' | ||
- | < | ||
- | [username@l32]$ module avail # select a matlab version | ||
- | [username@l32]$ module load Matlab/ | ||
- | [username@l32]$ module list # check loaded modules | ||
- | Currently Loaded Modulefiles: | ||
- | 1) Matlab/ | ||
- | </ | ||
- | (See also the introduction to the [[https:// | ||
- | Now, Matlab can be called by | ||
- | < | ||
- | [username@l32]$ matlab | ||
- | </ | ||
- | ==== Example: Serial Matlab Task ==== | ||
- | |||
- | We use the matlab m-file {{doku: | ||
- | < | ||
- | #!/bin/bash | ||
- | # | ||
- | #SBATCH -J test # job name | ||
- | #SBATCH -N 1 # number of nodes | ||
- | #SBATCH --ntasks-per-node=1 | ||
- | #SBATCH --ntasks-per-core=1 | ||
- | #SBATCH --threads-per-core=1 | ||
- | #SBATCH --time=10 | ||
- | #SBATCH -L matlab@vsc | ||
- | |||
- | module purge | ||
- | module load Matlab/ | ||
- | |||
- | export OMP_NUM_THREADS=1 | ||
- | |||
- | time matlab < myplot.m | ||
- | </ | ||
- | |||
- | < | ||
- | [username@l32]$ sbatch jobSerial.sh | ||
- | [username@l32]$ squeue -u username | ||
- | </ | ||
- | ==== Example: Local Matlabpool ==== | ||
- | We use the m-file '' | ||
- | |||
- | == jobPool.sh == | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | # | ||
- | #SBATCH -J test # job name | ||
- | #SBATCH -N 1 # number of nodes | ||
- | #SBATCH --ntasks-per-node=16 | ||
- | #SBATCH --ntasks-per-core=1 | ||
- | #SBATCH --threads-per-core=1 | ||
- | #SBATCH --time=100 | ||
- | #SBATCH -L matlab@vsc | ||
- | |||
- | module purge | ||
- | module load Matlab/ | ||
- | |||
- | export OMP_NUM_THREADS=1 | ||
- | |||
- | time matlab < main.m | ||
- | </ | ||
- | |||
- | == main.m == | ||
- | |||
- | < | ||
- | matlabpool %open local 8 % local profile is default setting, at most 8 workers are allowed with the local scheduler | ||
- | |||
- | matlabpool size | ||
- | |||
- | n = 500; K = 50; L = 10; T = zeros(1,L); | ||
- | |||
- | % serial inner loop | ||
- | for l = 1:L | ||
- | tic | ||
- | for k = 1:K | ||
- | eig(rand(n)); | ||
- | end | ||
- | T(l) = toc; | ||
- | end | ||
- | |||
- | disp([' | ||
- | |||
- | % parallel inner loop | ||
- | for l = 1:L | ||
- | tic | ||
- | parfor k = 1:K | ||
- | eig(rand(n)); | ||
- | end | ||
- | T(l) = toc; | ||
- | end | ||
- | |||
- | disp([' | ||
- | |||
- | matlabpool close | ||
- | </ | ||
- | |||
- | == command line on the login node == | ||
- | |||
- | < | ||
- | [username@l32]$ sbatch jobPool.sh | ||
- | [username@l32]$ squeue -u username | ||
- | </ |