If you are new to the command-line interface (CLI) and do not know how to edit files in CLI, please refer to this page for a tutorial of using the text editor nano.
A SLURM file has two parts: 1) The #SBATCH directives and 2) the commands you want to execute within the job.
Here is an example file named “example.slurm“:
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --mem-per-cpu=1G
#SBATCH --time=01:00:00
#SBATCH --partition=week-long-cpu
#SBATCH --job-name=HelloWorld
#SBATCH --error=job.%J.err
#SBATCH --output=job.%J.out
echo "HelloWorld"
sleep 300
The script above will request for 1 node, 4 cores, 4Gb memory (1G per core), 1 hour run time on the partition named ‘week-long-cpu’. The job name is ‘HelloWorld’. This job will print ‘HelloWorld’ to the output file then stay idle for another 300 seconds.
General SLURM directives:
- nodes
Number of nodes requested - ntasks-per-node
Number of cores per node. For example, if –nodes=2 and –ntasks-per-node=2, then a total of 4 cores will be requested. - ntasks
Total number of cores regardless of the node number. For example, if –nodes=2 and –ntasks=4, then a total number of 4 cores will be requested. It could allocate 1 core on 1 node, 3 cores on the other node, or 2 cores each. - mem-per-cpu
Memory that is allocated per core for the job. If you exceed this memory limit, your job will be stopped. - mem
Specify the real memory required per node in MegaBytes. If you exceed this limit, your job will be stopped. Note that for you should ask for less memory than each node actually has. - time
Maximum walltime the job can run. After this time has expired, the job will be stopped. - job-name The name of the job. Will be reported in the job listing.
- partition
The partition the job should run in. Partitions determine the job’s priority and on what nodes the partition can run on. - error
Location of the stderr will be written for the job. - output
Location of the stdout will be written for the job.
To submit this job to the cluster, use the sbatch command:
sbatch example.slurm
SLURM Job Notification
#SBATCH --mail-user=YOUR_EMAIL_ADDRESS@emory.edu
#SBATCH --mail-type=ALL #Send all job status to the email address above
Valid type values are NONE, BEGIN, END, FAIL, REQUEUE, ALL (equivalent to BEGIN, END, FAIL, REQUEUE, and STAGE_OUT), STAGE_OUT (burst buffer stage out and teardown completed), TIME_LIMIT, TIME_LIMIT_90 (reached 90 percent of time limit), TIME_LIMIT_80 (reached 80 percent of time limit), TIME_LIMIT_50 (reached 50 percent of time limit) and ARRAY_TASKS (send emails for each array task). Multiple type values may be specified in a comma separated list.