Difference between revisions of "Cluster matlab"

From Biomedical Optics Lab
Jump to navigationJump to search
Line 12: Line 12:
  
 
# Set SLURM options (you should not need to change these)
 
# Set SLURM options (you should not need to change these)
#SBATCH --job-name=testing                         # Job name
+
#SBATCH --job-name=testing                     # Job name
#SBATCH --output=./test-results/testing-%j.out                     # Name for output log file (%j is job ID)
+
#SBATCH --output=./test-results/testing-%j.out # Name for output log file (%j is job ID)
 
#SBATCH --nodes=1                              # Requesting 1 node and 1 task per node should
 
#SBATCH --nodes=1                              # Requesting 1 node and 1 task per node should
 
#SBATCH --ntasks-per-node=1                    # ensure exclusive access to the node
 
#SBATCH --ntasks-per-node=1                    # ensure exclusive access to the node
#SBATCH --cpus-per-task=32                       # Limit the job to only two cores
+
#SBATCH --cpus-per-task=32                     # Limit the job to only two cores
#SBATCH --partition=short                   # Partition (queue)  
+
#SBATCH --partition=short                       # Partition (queue)  
 
#SBATCH --time=00:15:00                        # Time limit hrs:min:sec
 
#SBATCH --time=00:15:00                        # Time limit hrs:min:sec
 
  
 
# DONT MODIFY ANYTHING ABOVE THIS LINE
 
# DONT MODIFY ANYTHING ABOVE THIS LINE
Line 30: Line 29:
  
 
echo -e "\n# Run Results -------------------------"
 
echo -e "\n# Run Results -------------------------"
matlab -nodisplay -nosplash -nodesktop -r "run('./parforcluster.m');exit;"
+
matlab -nodisplay -nosplash -nodesktop -r "run('./parforcluster.m');exit;" # Run the Matlab script
#matlab -r "parpool"
+
 
 
# For reference, dump info about the processor
 
# For reference, dump info about the processor
 
echo -e "\n# CPU Info ----------------------------"
 
echo -e "\n# CPU Info ----------------------------"
 
lscpu
 
lscpu
 
</pre>
 
</pre>

Revision as of 12:37, 25 June 2020

Using Matlab on the Cluster

We are exploring how to use Matlab with the new HPC cluster, and we will use this page to keep track of our current approaches.

Running Matlab Code Using Slurm

To properly use the cluster, we must submit jobs using the Slurm scheduler. To run an existing Matlab script, we just include its name in the Slurm instructions. Here is an example for running the Matlab code parforcluster.m. The text below could be named ada-submit and used for running all Matlab scripts by updating the filename inside the Matlab run command matlab -nodisplay -nosplash -nodesktop -r "run('./parforcluster.m');exit;".

#!/usr/bin/env bash
# 
# submit batch file; based on CS 416 S20 ada-submit 

# Set SLURM options (you should not need to change these)
#SBATCH --job-name=testing                      # Job name
#SBATCH --output=./test-results/testing-%j.out  # Name for output log file (%j is job ID)
#SBATCH --nodes=1                               # Requesting 1 node and 1 task per node should
#SBATCH --ntasks-per-node=1                     # ensure exclusive access to the node
#SBATCH --cpus-per-task=32                      # Limit the job to only two cores
#SBATCH --partition=short                       # Partition (queue) 
#SBATCH --time=00:15:00                         # Time limit hrs:min:sec

# DONT MODIFY ANYTHING ABOVE THIS LINE

# Print SLURM envirionment variables
echo "# Job Info ----------------------------"
echo "Job ID: ${SLURM_JOB_ID}"
echo "Node: ${SLURMD_NODENAME}"
echo "Starting: "`date +"%D %T"`

echo -e "\n# Run Results -------------------------"
matlab -nodisplay -nosplash -nodesktop -r "run('./parforcluster.m');exit;"  # Run the Matlab script

# For reference, dump info about the processor
echo -e "\n# CPU Info ----------------------------"
lscpu