===== MATLAB Jobs ===== ==== MATLAB serial job ==== === Execution of a MATLAB serial program === cp -p /hpc/share/samples/matlab/pi_greco.m . Script ''matlab.sh'': #!/bin/sh #SBATCH --job-name=matlab #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --tasks-per-node=1 #SBATCH --partition=vrt #SBATCH --mem=8G #SBATCH --time=00:30:00 #SBATCH --account= module load matlab/R2017a matlab -nodisplay -r pi_greco Submitting ''matlab.sh'': sbatch matlab.sh ==== MATLAB parallel job ==== [[https://www.mir.wustl.edu/Portals/0/Documents/Uploads/CHPC/PCT_Masterclass.pdf|Parallel Computing with MATLAB]] === Execution of a parallel job with MATLAB === cp -p /hpc/share/samples/matlab/pi_greco_parallel.m . Script ''matlab_parallel.sh'': #!/bin/sh #SBATCH --job-name=matlab_parallel #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --tasks-per-node=4 #SBATCH --partition=bdw #SBATCH --mem=8G #SBATCH --time=0-00:30:00 #SBATCH --account= module load matlab/R2017a matlab -nodisplay -r pi_greco_parallel Submitting ''matlab_parallel.sh'': sbatch matlab_parallel.sh ==== MATLAB GPU job ==== === Execution of a MATLAB program on GPU === In this example we see how to run the [[https://it.mathworks.com/matlabcentral/fileexchange/34080-gpubench|GPUBench]] MATLAB program on GPU. Requires the MATLAB Parallel Computing Toolbox and a GPU with CUDA Compute Capability. Script ''slurm-matlab-gpu-bench.sh'': #!/bin/sh #SBATCH --job-name=GPUBench #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --tasks-per-node=1 #SBATCH --gres=gpu:tesla:1 #SBATCH --partition=gpu #SBATCH --mem=8G #SBATCH --time=0-00:30:00 #SBATCH --account= module load matlab/R2017a cd 'GPUBench_v1.10' matlab -nodisplay -nosplash -r "T=gpuBench;quit" Submitting ''slurm-matlab-gpu-bench.sh'': sbatch slurm-matlab-gpu-bench.sh === Execution of two MATLAB programs on the same GPU === In this example we see how to run two instances of the [[https://it.mathworks.com/matlabcentral/fileexchange/34080-gpubench|GPUBench]] MATLAB program on the same GPU. Requires the MATLAB Parallel Computing Toolbox and a GPU with CUDA Compute Capability. Script ''slurm-matlab-multi-gpu-bench.sh'': #!/bin/sh #SBATCH --job-name=GPUBench #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --tasks-per-node=1 #SBATCH --gres=gpu:tesla:1 #SBATCH --partition=gpu #SBATCH --mem=8G #SBATCH --time=0-00:30:00 #SBATCH --account= module load matlab/R2017a cd 'GPUBench_v1.10' pids="" for i in $(seq 0 1); do matlab -nodisplay -nosplash -r "T=gpuBench;quit" \ 1>"$SLURM_SUBMIT_DIR/${SLURM_JOB_NAME}.o${SLURM_JOB_ID}.${i}" \ 2>"$SLURM_SUBMIT_DIR/${SLURM_JOB_NAME}.e${SLURM_JOB_ID}.${i}" & pids="${pids:+$pids }$!" done echo "Waiting PID(s): $pids" wait $pids Submitting ''slurm-matlab-multi-gpu-bench.sh'': sbatch slurm-matlab-multi-gpu-bench.sh