A submission script is a shell script that consists of a list of processing tasks that need to be carried out, such as the command, runtime libraries, and input and/or output files for the tasks. If you know the resources that your tasks need to consume, you may also modify the SBATCH script with some of the common directives, e.g.:
Short Format Long Format Description
------------ ----------- -----------
-n count --ntasks Controls the number of tasks to be created for the job
-t HH:MM:SS --time=HH:MM:SS Always specify the maximum wallclock time for your job, max is 7 days.
-p partition --partition=partition Always specify your partition
N/A --ntasks-per-node Controls the maximum number of tasks per allocated node
-c count --cpus-per-task Controls the number of CPUs allocated per task
N/A --mem-per-cpu Memory size per CPU
-m size --mem=size Total memory size
-J jobname --job-name=job_name Up to 15 printable, non-whitespace characters
N/A --gres=gpu:1 Generic consumable resources e.g. GPU
-o output-name --output=output-name specify custom job output file name (if needed)
-e error-name --error=error-name specify custom job error file name (if needed)
Submitting a job to SLURM is performed by running the sbatch
command and specifying a job script.
sbatch run.job
You can supply options (e.g. --ntasks=xx
) to the sbatch
command. If an option is already defined in the run.job
file, it will be overridden by the command line argument.
sbatch [options] job.script
#!/bin/bash
#SBATCH --job-name=test01
#SBATCH --time=10:00
#SBATCH --mem=8192
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --partition=cpu1,cpu2
sleep 600
This script describes the job: it is a serial job with only one process (--ntasks=1
). It only needs one CPU core to run the sleep
process. The maximum memory for this job has been set to 8GB and you should adjust the script based on how much your job needs.
Interactive mode allow you to connect to the compute node and do your work. This mode will be useful if want to see the output directly, test your code and make sure it run as sexpected before putting together a script and submit using sbatch
.
To launch an interactive mode, below is an example command:
srun --mem=4G --pty bash
This will submit a job to run interactively with 4GB memory and only 1 logical CPU. You can refer to above directive for different option. After running this, you should see your terminal prompt changed to the compute node or it will show that it currently queuing.