Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
doku:matlab [2020/01/16 12:46] – [Run Matlab Task from command line] irdoku: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 'module load xyz' command 
-<code> 
-[username@l32]$ module avail  # select a matlab version 
-[username@l32]$ module load Matlab/v9.5_R2018b # load desired version 
-[username@l32]$ module list   # check loaded modules 
-Currently Loaded Modulefiles: 
-  1) Matlab/v9.5_R2018b     
-</code> 
-(See also the introduction to the [[https://wiki.vsc.ac.at/doku.php?id=doku:slurm|module command.]]) 
  
-Now, Matlab can be called by 
-<code> 
-[username@l32]$ matlab   
-</code> 
-==== Example: Serial Matlab Task ==== 
- 
-We use the matlab m-file {{doku:myplot.m|myplot.m}} and create a file called ''jobSerial.sh'' as your job script, with the following basic contents: 
-<code> 
-#!/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                   # run time unit=minutes 
-#SBATCH -L matlab@vsc 
- 
-module purge 
-module load Matlab/v9.5_R2018b # load desired version 
- 
-export OMP_NUM_THREADS=1 
- 
-time matlab < myplot.m 
-</code> 
- 
-<code> 
-[username@l32]$ sbatch jobSerial.sh   # submit your job 
-[username@l32]$ squeue -u username    # check state of your job 
-</code> 
-==== Example: Local Matlabpool ==== 
-We use the m-file ''main.m'' and create the following shellscript ''jobPool.sh'' 
- 
-== jobPool.sh == 
- 
-<code> 
-#!/bin/bash 
-# 
-#SBATCH -J test                     # job name 
-#SBATCH -N 1                        # number of nodes 
-#SBATCH --ntasks-per-node=16        # here we use all 16 cores of the node 
-#SBATCH --ntasks-per-core=1 
-#SBATCH --threads-per-core=1 
-#SBATCH --time=100                   # run time unit=minutes 
-#SBATCH -L matlab@vsc 
- 
-module purge 
-module load Matlab/v9.5_R2018b # load desired version 
- 
-export OMP_NUM_THREADS=1 
- 
-time matlab < main.m 
-</code> 
- 
-== main.m == 
- 
-<code> 
-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(['serial: ',num2str(mean(T))]) 
- 
-% parallel inner loop 
-for l = 1:L 
-tic 
-parfor k = 1:K 
-    eig(rand(n)); 
-end 
-T(l) = toc; 
-end 
- 
-disp(['parallel: ',num2str(mean(T))]) 
- 
-matlabpool close 
-</code> 
- 
-== command line on the login node == 
- 
-<code> 
-[username@l32]$ sbatch jobPool.sh     # submit your job 
-[username@l32]$ squeue -u username    # check state of your job 
-</code> 
  • doku/matlab.txt
  • Last modified: 2024/05/14 08:11
  • by fkocina