Batch Jobs

Introduction

With a batch job, you submit your job through the scheduler. Your job will run automatically as soon as the resources are available. For more information about Batch jobs, refer you to the Batch Job & Interactive Job Submissions guide in our Helpful References.

The sbatch command

The sbatch command is used for submitting jobs to the cluster. The command accepts a number of options either from the command line, or (more typically) from a batch script. An example of a SLURM batch script (called simple.slurm) is shown below:

#!/bin/bash

#SBATCH -N 1 

#SBATCH -c 1 

#SBATCH --mem-per-cpu=1G 

#SBATCH --time=0-00:15:00 # 15 minutes 

#SBATCH --output=my.stdout 

#SBATCH --mail-user=abac123@case.edu 

#SBATCH --mail-type=ALL 

#SBATCH --job-name="just_a_test" 

# Put commands for executing job below this line 

# This example is loading the default Python module and then 

# writing out the version of Python 

module load python 

python --version

To submit this batch script, a user would type:

sbatch simple.slurm

This job (called just_a_test) requests 1 compute node, 1 task (by default, SLURM will assign 1 CPU core per task), 1 GB of RAM per CPU core, and 15 minutes of wall time (the time required for the job to complete). Note that these are the defaults for any job, but it is good practice to include these lines in a SLURM script in case you need to request additional resources.

Command Line Options

Optionally, any #SBATCH line may be replaced with an equivalent command-line option. For instance, the #SBATCH –ntasks=1 line could be removed and a user could specify this option from the command line using:

sbatch --ntasks=1 simple.slurm

The commands needed to execute a program must be included beneath all #SBATCH commands. Lines beginning with the # symbol (without /bin/bash or SBATCH) are comment lines that are not executed by the shell. The example above simply prints the version of Python loaded in a user’s path. It is good practice to include any setpkgs commands in your SLURM script. A real job would likely do something more complex than the example above, such as read in a Python file for processing by the Python interpreter.

For more information about sbatch see: http://slurm.schedmd.com/sbatch.html

For running GPU jobs, please find the available Software under the Section "GPU" in the "Software Guide" page.