==== 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/bash #SBATCH --job-name=GPUBench #SBATCH --output=%x.o%j #SBATCH --error=%x.e%j #SBATCH --nodes=1 #SBATCH --ntasks-per-node=1 #SBATCH --gres=gpu:1 #SBATCH --partition=gpu #SBATCH --qos=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 --ntasks-per-node=1 #SBATCH --gres=gpu:1 #SBATCH --partition=gpu #SBATCH --qos=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 [[calcoloscientifico:userguide:matlab|go back one level]]