Batch Jobs
Here's how to run an extremely simple batch job on the system. The following batch script, named simple_cmd.sh
, executes a few trivial shell commands rather than a real application:
#!/bin/bash
#SBATCH -p development
#SBATCH -t 00:01:00
#SBATCH -N 1
#SBATCH -n 1
# Print date
date
# Verify that sleep 5 works
time sleep 5
Notice that the script contains several special #SBATCH
comments. This is one way (in fact, the preferred way) to pass job attributes to Slurm. Doing so is necessary because the following attributes must be defined for every job on Frontera:
Meaning | Flag | Value | Example |
---|---|---|---|
Partition/queue name | -p |
queueName | -p normal |
Time limit (wall time) | -t |
hh:mm:ss | -t 00:05:00 |
Number of nodes | -N |
1..queueMaxNodes | -N 2 |
Number of tasksnodes | -n |
1..[nodes * cores] | -n 56 (good for MPI on 1 node) |
Project name (if you have > 1) | -A |
projectName | -A A-P12345 |
Note that --ntasks-per-node
is an acceptable alternative to the number of tasks (-n
), even for non-MPI jobs
sbatch
Having prepared the above script, we then submit it to Slurm with the sbatch
command.
$ sbatch simple_cmd.sh
Alternatively, Slurm job attributes may be entered on the sbatch
command line at the time the job is submitted:
$ sbatch -p development -t 00:01:00 -N 1 -n 1 -A <proj_name> simple_cmd.sh
If any command-line options conflict with those in the batch script, the ones on the command line take precedence. Most flags have a short form (e.g., -N
) and a long form (e.g., --nodes
).
Slurm has many more options that let you set various kinds of attributes for your jobs. We'll take a look at some of these optional job attributes in a later section.
Your job will run in the same environment that was present at submission time, which includes the modules that are loaded and the current working directory. In most cases the best practice is to submit your applications after loading the same modules that you used to build them.
Accordingly, one flag to avoid is --export
, which controls environment variables for your batch run. On Frontera, though, the use of this flag can lead to unexpected outcomes.