sbatch options
This page explains the options that you can use with sbatch, either in #SBATCH lines in a job script or on the command line. Command line options override those in the script. It covers the most useful ones: for the full list, run man sbatch.
New to Slurm? Start with your first job.
Slurm stops reading #SBATCH lines at the first command in a script, and any later ones are silently ignored. Each option has a short form, a long form, or both.
Required on COSMA
Jobs are rejected without these.
Option |
Example |
Meaning |
|---|---|---|
|
|
The project to charge |
|
|
The queue: see queues |
|
|
The time limit |
Time can be given as MM, HH:MM:SS or D-HH:MM:SS. Most queues allow up to 3 days. Request a realistic time, because shorter jobs can often start sooner.
CPUs and tasks
A task is one copy of your program, usually an MPI rank. A CPU is one core on most COSMA queues.
Option |
Example |
Meaning |
|---|---|---|
|
|
The total number of tasks |
|
|
CPUs for each task, usually for OpenMP threads |
|
|
The number of nodes |
|
|
Tasks to run on each node |
|
|
Hardware threads to use on each core |
|
Do not share nodes with other jobs |
Some common patterns are:
Job |
Options |
|---|---|
One program on one CPU |
|
OpenMP on 16 CPUs |
|
MPI on 1024 CPUs |
|
Hybrid on 4 COSMA8 nodes |
|
Threads and CPUs
On COSMA, Slurm allocates whole cores, and each core has two hardware threads. A job with --cpus-per-task=4 gets 4 cores but can see 8 threads, so programs that use nproc to choose how many threads to start will start 8.
To run one thread on each core, set the number of threads yourself:
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
--threads-per-core=1 also limits job steps started with srun, but not the job script itself. See MPI hints for pinning.
Exclusive access
Queues differ in whether jobs share nodes:
Queue |
Sharing |
|---|---|
|
Always whole nodes, so |
|
Shared. |
Memory
On whole-node queues, your job gets all of the memory on its nodes. On shared queues, please say how much you need.
Option |
Example |
Meaning |
|---|---|---|
|
|
Memory for each node |
|
|
Memory for each CPU |
Use one or the other. Values can use K, M, G or T, and the default unit is megabytes. Jobs that use more than this are killed. The default memory per CPU depends on the queue: see the shm queues.
Choosing nodes
Option |
Example |
Meaning |
|---|---|---|
|
|
Run on these nodes |
|
|
Do not use these nodes |
|
|
Use nodes with this feature |
|
|
Request generic resources: see GPU jobs |
COSMA8 has two types of node. To use only one, select the cosma8-rome or cosma8-milan queue.
Output
Option |
Example |
Meaning |
|---|---|---|
|
|
The name of the job |
|
|
The file for standard output |
|
|
The file for errors. Without this, errors go to the output file |
|
|
Add to files instead of replacing them |
|
|
The directory to run in |
The default is the directory that you submit from, and an output file called slurm-JOBID.out.
File names can use these patterns:
Pattern |
Meaning |
|---|---|
|
Job number |
|
Job name |
|
Job number of an array |
|
Task number in an array |
|
Name of the first node |
|
User name |
Email
Option |
Example |
Meaning |
|---|---|---|
|
|
When to send email. Other values include |
|
|
Where to send it |
Controlling when a job runs
Option |
Example |
Meaning |
|---|---|---|
|
|
Do not start before this time |
|
|
Wait for another job: see dependencies |
|
|
Cancel the job if its dependency can never be met |
|
Hold the job until you run |
|
|
|
Accept a shorter time limit if this means that the job starts sooner |
|
|
Lower the priority of your job, to let others go first |
|
|
Send a signal before the time limit: see saving work |
|
Allow the job to restart from the beginning after a node failure. This is off by default on COSMA, and does not apply if your program fails |
Other useful options
Option |
Example |
Meaning |
|---|---|---|
|
|
Run many similar tasks: see job arrays |
|
|
Run a command, without a script |
|
Check the job and estimate when it would start, without submitting it |
|
|
Print only the job number, which is useful in scripts |
|
|
|
Choose which environment variables to pass to the job |
|
Wait until the job finishes before returning |
By default, your job inherits the environment of the shell that you submit it from, including any loaded modules. It is safest to run module purge, then load what you need, in your job script.