User Tools

Site Tools


howto:matlab

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howto:matlab [2025/04/02 13:46]
kevin
howto:matlab [2025/05/22 16:56] (current)
kevin [Example job script]
Line 31: Line 31:
 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. 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.+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. 
 + 
 +<code bash> 
 +#!/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." 
 +</code> 
 + 
 +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. 
  
  
/app/dokuwiki/data/attic/howto/matlab.1743594364.txt.gz · Last modified: 2025/04/02 13:46 by kevin