Raad2: Matlab

From TAMUQ Research Computing User Documentation Wiki
Jump to navigation Jump to search

BatchJob File

#SBATCH -J matDemo
#SBATCH -p express
#SBATCH --qos=ex
#SBATCH --time=00:05:00
#SBATCH --hint=nomultithread
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=12
#SBATCH --output=matDemo.o%j
#SBATCH --error=matDemo.e%j
#SBATCH --gres=craynetwork:0

echo "Starting at $(date)"
echo "SLURM_JOBID         = $SLURM_JOBID"
echo "Working directory   = $SLURM_SUBMIT_DIR"

export TMP="/ddn/home/$USER/tmp"
export MATLAB_VER="r2016a"

module load matlab/$MATLAB_VER

echo "Starting simulation with Matlab $MATLAB_VER..."

srun matlab -nodisplay -nosplash -r myscript

echo "Simulation ending at $(date)..."

Matlab Script myscript.m

disp(['Num threads being used: ' num2str(cpus)])
disp(['Current working dir: ' workdir])
disp(['Current TMP dir: ' tempfolder])

Interactive Mode

Interactive mode is not the preferred way to run MATLAB computations on a HPC Cluster as it results in inefficient use of an expensive shared resource. However, when such use is necessary for testing and debugging your codes, you may run in interactive mode by following these instructions:

muarif092@raad2a:~> ssh raad2-login2
muarif092@raad2-login2:~> srun --pty --qos ex -p express --gres=craynetwork:0 --time=01:00:00 /bin/bash
  1. Refer to this link and setup Display variable on compute node. https://rc-docs.qatar.tamu.edu/index.php/Raad2_faqs#Setup_X11_forwarding
  2. Now load matlab module and launch matlab.
muarif092@nid00444:~> module load matlab/r2016a
muarif092@nid00444:~> matlab

Note that the module load command determines which version of matlab launches with the subsequent matlab command. If you needed the R2021a version for example, you would use module load matlab/r2021a instead.