Slurm Example using “sbatch”

Note: you need to sign into the Psychology cluster (neurocomp0) to run the following commands.

Note: put two number signs “##” at the beginning of a line to comment it out.

Note: you’ll get an email when the job starts and an email when the job finishes if you provide –mail-user (remove a number sign # to uncomment the line first).

#!/bin/bash
#SBATCH --job-name="slurmTest"
#SBATCH --partition=cpu
#SBATCH --nodes=1
#SBATCH --ntasks=2
#SBATCH --cpus-per-task=1
#SBATCH --mem=23000
#SBATCH --output=slurmTest.out
##SBATCH --mail-user=YOUR_EMAIL_ADDRESS
#SBATCH --mail-type=ALL

##SBATCH --time=00:15:00
##SBATCH --requeue      #Specifies that the job will be requeued after a node failure.The default is that the job will not be requeued.
##SBATCH --checkpoint=1:0:0

hostname
date +'%y-%m-%d %H:%M:%S'
which python
python --version
module load python
which python
python --version
module unload python
which python
python --version
date +'%y-%m-%d %H:%M:%S'

Note: this example will ask for

  • 1 node (#SBATCH –nodes=1)
  • 2 CPU cores (#SBATCH –ntasks=2, #SBATCH –cpus-per-task=1)
  • 2.3GB RAM (#SBATCH –mem=23000)
  • redirect standard output / error to “slurmTest.out” file (#SBATCH –output=slurmTest.out)

To run the example (SBATCH_EXAMPLE.sh, for example), sign into the head node, open a terminal and run:

sbatch SBATCH_EXAMPLE.sh
Here is an example output:
neurocomp2
19-06-28 10:33:57
/usr/bin/python
Python 2.7.15+
/pkgs/anaconda3/bin/python
Python 3.7.3
/usr/bin/python
Python 2.7.15+
19-06-28 10:33:57