Creating sbatch script
A skeleton Slurm script
<source lang='bash'>
- -----------------------------Mail address-----------------------------
- SBATCH --mail-user=
- SBATCH --mail-type=ALL
- -----------------------------Output files-----------------------------
- SBATCH --output=output_%j.txt
- SBATCH --error=error_output_%j.txt
- -----------------------------Other information------------------------
- SBATCH --comment=
- SBATCH --account=
- -----------------------------Required resources-----------------------
- SBATCH --partition=
- SBATCH --time=0-0:0:0
- SBATCH --ntasks=
- SBATCH --cpus-per-task=
- SBATCH --mem-per-cpu=
- -----------------------------Environment, Operations and Job steps----
- load modules
- export variables
- your job
</source>
Explanation of used SBATCH parameters
Adding accounting information or project number
<source lang='bash'>
- SBATCH --account=773320000
</source> Charge resources used by this job to specified account. The account is an arbitrary string. The account name may be changed after job submission using the scontrol command. For WUR users a projectnumber or KTP number would be advisable.
time limit
<source lang='bash'>
- SBATCH --time=1200
</source> A time limit of zero requests that no time limit be imposed. Acceptable time formats include "minutes", "minutes:seconds", "hours:minutes:seconds", "days-hours", "days-hours:minutes" and "days-hours:minutes:seconds". So in this example the job will run for a maximum of 1200 minutes.
memory limit
<source lang='bash'>
- SBATCH --mem=2048
</source> SLURM imposes a memory limit on each job. By default, it is deliberately relatively small — 100 MB per node. If your job uses more than that, you’ll get an error that your job Exceeded job memory limit. To set a larger limit, add to your job submission: <source lang='bash'>
- SBATCH --mem X
</source>
where X is the maximum amount of memory your job will use per node, in MB. The larger your working data set, the larger this needs to be, but the smaller the number the easier it is for the scheduler to find a place to run your job. To determine an appropriate value, start relatively large (job slots on average have about 4000 MB per core, but that’s much larger than needed for most jobs) and then use sacct to look at how much your job is actually using or used:
<source lang='bash'> $ sacct -o MaxRSS -j JOBID </source> where JOBID is the one you’re interested in. The number is in KB, so divide by 1024 to get a rough idea of what to use with –mem (set it to something a little larger than that, since you’re defining a hard upper limit). If your job completed long in the past you may have to tell sacct to look further back in time by adding a start time with -S YYYY-MM-DD. Note that for parallel jobs spanning multiple nodes, this is the maximum memory used on any one node; if you’re not setting an even distribution of tasks per node (e.g. with –ntasks-per-node), the same job could have very different values when run at different times.
number of tasks
<source lang='bash'>
- SBATCH --ntasks=1
</source> sbatch does not launch tasks, it requests an allocation of resources and submits a batch script. This option advises the SLURM controller that job steps run within the allocation will launch a maximum of number tasks and to provide for sufficient resources. The default is one task per node, but note that the --cpus-per-task option will change this default.
When requesting multiple tasks, you may or may not want the job to be partitioned among multiple nodes. You can specify the minimum number of nodes using the -N
or --node
flag. If you provide only one number, this will be minimum and maximum at the same time. For instance:
<source lang='bash'>
- SBATCH --nodes=1
</source> This should force your job to be scheduled to a single node.
Because the cluster has a hybrid configuration, i.e. normal and fat nodes, it may be prudent to schedule your job specifically for one or the other node type, depending for instance on memory requirements. This can be done by using the -C
or --constraints
flag.
constraints: selecting the normal or fat nodes
<source lang='bash'>
- SBATCH --constraint=normalmem
</source>
The example above will result in jobs being scheduled to the regular compute nodes. By using largemem
as option the job will specifically be scheduled to one of the fat nodes.
output (stderr,stdout) directed to file
<source lang='bash'>
- SBATCH --output=output_%j.txt
</source> Instruct SLURM to connect the batch script's standard output directly to the file name specified in the "filename pattern". By default both standard output and standard error are directed to a file of the name "slurm-%j.out", where the "%j" is replaced with the job allocation number. See the --input option for filename specification options. <source lang='bash'>
- SBATCH --error=error_output_%j.txt
</source> Instruct SLURM to connect the batch script's standard error directly to the file name specified in the "filename pattern". By default both standard output and standard error are directed to a file of the name "slurm-%j.out", where the "%j" is replaced with the job allocation number. See the --input option for filename specification options.
adding a job name
<source lang='bash'>
- SBATCH --job-name=calc_pi.py
</source> Specify a name for the job allocation. The specified name will appear along with the job id number when querying running jobs on the system. The default is the name of the batch script, or just "sbatch" if the script is read on sbatch's standard input.
partition for resource allocation
<source lang='bash'>
- SBATCH --partition=ABGC_Std
</source> Request a specific partition for the resource allocation. It is prefered to use your organizations partition.
receiving mailed updates
<source lang='bash'>
- SBATCH --mail-type=ALL
</source> Notify user by email when certain event types occur. Valid type values are BEGIN, END, FAIL, REQUEUE, and ALL (any state change). The user to be notified is indicated with --mail-user. <source lang='bash'>
- SBATCH --mail-user=email@org.nl
</source> Email address to use.