MATLAB Usage
Using Matlab via CLI
Some options of interest:
- --nodesktop - skips firing up the desktop at startup (if java is running it can be fired up later)
- --nojvm - skip loading of Java, this means that no desktop can be started up
- --nosplash - skip trying to load the splash screen
matlab --nodesktop --nojvm --nosplash
Example Slurm Script
#!/bin/bash
## Two hashtags to create a comment
##
## NOTE
## - time limit not included here
## - parpool requires jvm
## SLURM REQUIRED SETTINGS
#SBATCH --partition=debug
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=44
## SLURM reads %x as the job name and %j as the job ID
#SBATCH --output=%x-%j.out
#SBATCH --error=%x-%j.err
## Executes bash commands to run your job
## OPEN MATLAB AND RUN YOUR SCRIPT
##
/home/matlab/R2017a/bin/matlab -nodesktop -nodisplay -nosplash < /home/<username>/script.m
Memory Optimization Tricks
Things the user can do to prevent out of memory errors:
- Set variables to empty instead of clear between runs (eg x =[ ]) <- this might solve cumulative loss of memory
- Preallocate variables at the start (grab's contiguous memory blocks)
- Clear any global variables
- Run matlab with -nojvm (no java, if you're not using parallel processing)
- Vector variables as columns instead of rows
- Only load parts of things at a time using matfile.m (or write your code to work similarly)