SLURM batch example¶
Single task, 32 cores/thread reserved, CPU bound process¶
We are giving here the example of a single task with 32 cores/thread allocated. The task will be enqueued to the queue called "all". We are also asking SLURM to send us a mail when the task starts, when the task completes and when a task is killed by an error. Finally, we are suggesting to SLURM that the task is mainly CPU bound.
After these directives, we are calling our bash script (which will execute the tasks).
#!/bin/bash # #SBATCH --job-name=test-job #SBATCH --partition=all #SBATCH --ntasks=1 #SBATCH --cpus-per-task=32 #SBATCH --mail-user=your@email.address #SBATCH --mail-type=ALL #SBATCH --mem-per-cpu=10G srun ./my_task_script.sh
We will name this script my_batch_script.sh and will launch it with a
sbatch my_batch_script.shPlease, note that the
--mem-per-cpudirective must be set according to your task needs, so you have to get approximately an idea of how much RAM memory should be reserved to your task. Please, do not overload this parameter: reserving resources that you will not use is a waste of resources that could be used by other users. The same is valid for the
--cpus-per-taskparameter.
Please, keep in mind that with this batch script you are just declaring to the workload manager what you are going to use, what you need, what you want to be reserved to your task. Then, accordingly, you should pass the right arguments to the software tools you are launching. E.g.: you declare
--cpus-per-task=32in the batch script, then you will have to tell your software to use 32 threads.
Mr Bayes MPI (mpich2) task, 44 tasks total, 2 nodes, 22 tasks per node¶
Write the following batch file (e.g. named my_batch_script.sh
)
#!/bin/bash
#
#SBATCH --job-name=MB_vulgaris
#SBATCH --partition=all
#SBATCH --nodes=2
#SBATCH --ntasks=44
#SBATCH --tasks-per-node=22
#SBATCH --mail-user=your@email.address
#SBATCH --mail-type=ALL
#SBATCH --hint=compute_bound
#SBATCH --mem-per-cpu=100G
module load mpi/mpich2-slurm
srun /opt/bin/mb_mpich ./linsi_new_candidates.falnt.alter.nex
Now submit your task to the queue with the command:
sbatch my_batch_script.sh