slurm examples

Examples, scripts

Example job submission files

'Job submission file' is the official SLURM name for the file you use to submit your program and ask for resources from the job scheduler. Here we will be using it interchangeably with 'script' or 'batch script'.

Commands to the batch scheduler is prefaced with #SBATCH, these are also called directives. You can also add normal shell commands to the script.

All SLURM directives can be given on the command line instead of in the script.

Remember - the scripts and all programs called by them, must be executable!

Examples, srun

Examples, srun

You can submit programs directly to the batch system with 'srun', giving all the command on the command line, though you should normally use a jobscript and submit it with 'sbatch', for larger or more complicated jobs.

More information about parameters and job submission files can be found on the Slurm submit file design page.

Running two tasks, each on a different core.

$ srun -A <account> -n 2 my_program

Run 6 tasks distributed across 2 nodes.

Slurm MPI + OpenMP examples

Slurm MPI + OpenMP examples

This example shows a hybrid MPI/OpenMP job with 4 tasks and 48 cores per task, on Abisko.

#!/bin/bash
# Example with 4 tasks and 48 cores per task for MPI+OpenMP
#
# Project/Account
#SBATCH -A hpc2n-1234-56
#
# Number of MPI tasks
#SBATCH -n 4
#
# Number of cores per task
#SBATCH -c 48
#
# Runtime of this jobs is less then 12 hours.
#SBATCH --time=12:00:00
#

# Set OMP_NUM_THREADS to the same value as -c
# with a fallback in case it isn't set.
# SLURM_CPUS_PER_TASK is set to the value of -c, but only if -c is explicitly set

Slurm OpenMP Examples

Slurm OpenMP Examples

This example shows a 48 core OpenMP Job (maximum size for one node on Abisko).

    #!/bin/bash
    # Example with 48 cores for OpenMP
    #
    # Project/Account
    #SBATCH -A hpc2n-1234-56
    #
    # Number of cores per task
    #SBATCH -c 48
    #
    # Runtime of this jobs is less then 12 hours.
    #SBATCH --time=12:00:00
    #

    # Set OMP_NUM_THREADS to the same value as -c
    # with a fallback in case it isn't set.
    # SLURM_CPUS_PER_TASK is set to the value of -c, but only if -c is explicitly set
Updated: 2017-09-21, 11:05