======Matlab====== ====Application to Access==== Matlab is commercial software and the CSIR has a site license which allows for non-commercial use on the CHPC cluster. ===If you are already a CHPC user:=== Please send an email to helpdesk@chpc.ac.za to request access to run Matlab M-files on the cluster. Please mention your use case and project. ===If you are not a CHPC user and would like to apply to be one:=== The CHPC is free for students and researchers and you can apply for a //normal user// account on our [[https://users.chpc.ac.za/|User Portal]] as described in our [[chpc:accounts#registration|Registrations guide]]. Note that after you register as a user, you will only receive a cluster account and access to a cpu-hour allocation once a CHPC //principal investigator// (PI) has added you to their research programme. If you are a student, then the PI would normally be your thesis supervisor. If they are not currently a CHPC PI, then they can register as a PI on our [[https://users.chpc.ac.za/|User Portal]] as described in the [[chpc:accounts#registration|Registrations guide]]. =====Environment Module===== Matlab 2020a is available by loading the shell environment module module load chpc/math/matlab/R2020a Note that you must include this command in your job scripts too in order to load Matlab into your job script environment. =====User Interface===== Note that you will only have access to the text mode user interface on the cluster. Make sure your M-files can run without needing the Matlab GUI. Additionally, your M-files need to be able to work non-interactively to run within a job script, i.e., using ''matlab -batch "command"''. ====Example job script==== > This job script assumes you want to use all 24 cores on one compute node. If your job needs fewer cores then change the ''-l'' parameter below, e.g., ''-l select=1:ncpus=8:mpiprocs=8'' and use ''-q serial'' instead of the ''smp'' queue. **Note:** set the ''walltime'' parameter to the maximum run time you expect your job to need. #!/bin/bash #PBS -N YOURJOBNAME #PBS -l select=1:ncpus=24:mpiprocs=24 #PBS -P YOURPROJECT #PBS -q smp #PBS -l walltime=0:30:00 CWD=/mnt/lustre/users/$USER/yourmatlabfiles/ cd $CWD echo "Working directory is" `pwd` echo module purge module load chpc/math/matlab/R2020a echo "Modules loaded:" module list |& cat echo echo "Matlab interpreter:" which matlab echo nproc=`cat $PBS_NODEFILE | wc -l` echo "nproc is $nproc" echo echo "Threads & nodes used by this job:" cat $PBS_NODEFILE | sort | uniq -c echo echo "This script is running on node" `hostname` echo echo "Starting run..." # Run matlab on the m-file hello.m matlab -batch "hello" echo echo "... done." If the ''matlab -batch "hello"'' command does not work then try the command matlab -nodesktop -nojvm < ./hello.m See the [[https://www.mathworks.com/help/matlab/ref/matlablinux.html|Matlab on Linux]] doc for more options.