Below you will find examples for three common scenarios (these headings will take you to the appropriate section, if you click on one).

The sections that follow will explain common circumstances in which each of those might be appropriate.

One node, one core

The most common scenarios is when you only need one processor on one physical node. This would be appropriate for most uses of programs like R, Stata/SE, Python, and many bioinformatics tools that are implemented in those languages. This type of job might be referred to as a serial job.

In this example, the script is asking for one processor on one physical node with 4 GB of memory available for 4 hours.

#!/bin/bash

# The name of the job
#SBATCH --job-name JOBNAME

# The name and location of the output file; this example format
# will put the output in your home directory and call the output
# file by the job name, a `-`, and finally the job number.  There
# are many options; see the sbatch man page, `filename pattern`
# section for more options and examples.  Make sure that the
# output directory exists *before* you submit the job!  Do *not*
# use any directory that is not available on all nodes, e.g., /tmp.

#SBATCH --output=/home/%u/%x-%j

##### Resources for your job

# number of physical nodes
#SBATCH --nodes=1

# number tasks (processes) per node; this will most commonly be the
# same number as the number of processors.  Each task will get one
# processor by default.
#SBATCH --ntasks-per-node=1

# memory per node
#SBATCH --mem=4g

#### Maximum amount of time the job will be allowed to run
####    Recommended formats:  MM:SS, HH:MM:SS, DD-HH:MM
#SBATCH --time=4:00:00

# Money matters; who pays
#SBATCH --account=test

# Which group of nodes (partition) should this job run in
#SBATCH --partition=standard

# Whom to send e-mail about the job; change to your e-mail address
#SBATCH --mail-user=username@umich.edu

# When to send e-mail: pick from NONE, BEGIN, END, FAIL, REQUEUE, ALL
#SBATCH --mail-type=NONE

# Your commands after this line

One node, multiple cores

This scenario is when you want multiple processors on the same physical node. Software that can use multiple processors on the same node is often called ‘threaded’ or ‘mulitcore’ or ‘multiprocessor’. Software such as Stata/MP and MATLAB can use multiple cores if they are present. Software like Python and R typically cannot unless special code to use them is used.

The following example asks for one node, with 4 processors and 12 GB of memory for 2 hours.

#!/bin/bash

# The name of the job
#SBATCH --job-name JOBNAME

# The name and location of the output file; this example format
# will put the output in your home directory and call the output
# file by the job name, a `-`, and finally the job number.  There
# are many options; see the sbatch man page, `filename pattern`
# section for more options and examples.  Make sure that the
# output directory exists *before* you submit the job!  Do *not*
# use any directory that is not available on all nodes, e.g., /tmp.

#SBATCH --output=/home/%u/%x-%j

##### Resources for your job

# number of physical nodes
#SBATCH --nodes=1

# number tasks (processes) per node; this will most commonly be the
# same number as the number of processors.  Each task will get one
# processor by default.
#SBATCH --ntasks-per-node=4

# memory per node
#SBATCH --mem=12g

#### Maximum amount of time the job will be allowed to run
####    Recommended formats:  MM:SS, HH:MM:SS, DD-HH:MM
#SBATCH --time=2:00:00

# Money matters; who pays
#SBATCH --account=test

# Which group of nodes (partition) should this job run in
#SBATCH --partition=standard

# Whom to send e-mail about the job; change to your e-mail address
#SBATCH --mail-user=username@umich.edu

# When to send e-mail: pick from NONE, BEGIN, END, FAIL, REQUEUE, ALL
#SBATCH --mail-type=NONE

# Your commands after this line

Multiple nodes, multiple cores

This scenario is for use only when you know your software can explicitly use more than one node. That is a special capability that must be programmed into the application. Many applications that can do this use the message passing interface (MPI) to communicate among the physical nodes and are often called ‘MPI-enabled’. Communication among nodes is much slower than on one node, so you should where possible try to use only multiple cores on a single node. Use this only when that is not feasible because of the required memory or the number of processors.

Used with MPI programs, MATLAB can do this with the parcluster('current'); both R and Python have ways to do this, but you must write the code yourself.

In this example, we are requesting 2 nodes, each with 8 processors, and we are now asking for the memory per processor (2 GB), so the total amount of memory requested will be 32 GB. We are requesting 2 hours of running time.

#!/bin/bash

# The name of the job
#SBATCH --job-name JOBNAME

# The name and location of the output file; this example format
# will put the output in your home directory and call the output
# file by the job name, a `-`, and finally the job number.  There
# are many options; see the sbatch man page, `filename pattern`
# section for more options and examples.  Make sure that the
# output directory exists *before* you submit the job!  Do *not*
# use any directory that is not available on all nodes, e.g., /tmp.

#SBATCH --output=/home/%u/%x-%j

##### Resources for your job

# number of physical nodes
#SBATCH --nodes=2

# number tasks (processes) per node; this will most commonly be the
# same number as the number of processors.  Each task will get one
# processor by default.
#SBATCH --ntasks-per-node=8

# memory per processor, not per node
#SBATCH --mem-per-cpu=2g

#### Maximum amount of time the job will be allowed to run
####    Recommended formats:  MM:SS, HH:MM:SS, DD-HH:MM
#SBATCH --time=2:00:00

# Money matters; who pays
#SBATCH --account=test

# Which group of nodes (partition) should this job run in
#SBATCH --partition=standard

# Whom to send e-mail about the job; change to your e-mail address
#SBATCH --mail-user=username@umich.edu

# When to send e-mail: pick from NONE, BEGIN, END, FAIL, REQUEUE, ALL
#SBATCH --mail-type=NONE

# Your commands after this line