Example Slurm Job
Here you will find a basic example job script for the Slurm batch system and further links for using the system.
Batch scripts are files that contain the definition of required hardware resources (see #SBATCH
lines) and the code you wish to run on an HPC compute node.
These batch scripts are submitted to Slurm using a unix console with the command sbatch
. Using the console is required to submit batch scripts using sbatch
.
Take the following code and save it to a file on your home directory in the cluster, using a file editor.
Basic example Slurm job script file
#!/usr/bin/zsh
### Start of Slurm SBATCH definitions
# Ask for eight tasks (same as 8 cores for this example)
#SBATCH --ntasks=8
# Ask for the maximum memory per core (most CLAIX-2023 nodes: 2.7GB per cpu)
#SBATCH --mem-per-cpu=2500M
# Ask for up to 15 Minutes of runtime
#SBATCH --time=00:15:00
# Name the job
#SBATCH --job-name=EXAMPLE_JOB
# Declare a file where the STDOUT/STDERR outputs will be written
#SBATCH --output=output.%J.txt
### end of Slurm SBATCH definitions
### your program goes here (hostname is an example, can be any program)
# `srun` runs `ntasks` instances of your programm `hostname`
srun hostname
After saving this example to a file ~/example.sh you can run the Slurm job by submitting it to Slurm using sbatch :
sbatch ~/example.sh
The previous example uses the zsh shell, which is the only officially supported shell at the RWTH HPC Claix Cluster.
Basic Slurm doumentation on hpc-wiki.info:
- What is a scheduler anyways and why should I bother using one?
- For basic documentation on Slurm please look here or at the official docs.
- Submit Jobs
- Write a job script
- Jobscript examples