Torque—>Slurm

You need to create a special script to run and queue a job at  Slurm using the sbatch command. The script contains information about the required resources (the number of cluster nodes, the number of processor cores, the required amount of RAM and the required time). Otherwise, this script is a regular bash script, you can set the necessary environment variables in it and run the necessary program. This script will only run on one core from the selected list.

Parameters in scripts:

Torque Slurm
#PBS -N myjob #SBATCH --job-name=myjob
#PBS -l walltime=1:00:00 #SBATCH --time=1:00:00
#PBS -l nodes=N:ppn=M #SBATCH --nodes=N --ntasks-per-node=M
#PBS -l mem=Xgb #SBATCH --mem=Xgb
#PBS -l pmem=Xgb #SBATCH --mem-per-cpu=Xgb
#PBS -q queue #SBATCH --partition queue

Commands:

Torque Slurm
qsub <jobscript> sbatch <jobscript>
qdel <jobid> scancel <jobid>
qhold <jobid> scontrol hold <jobid>
qrls <jobid> scontrol release <jobid>
qstat -u <user> squeue -u <user>
pbstop slurmtop

The main parameters of the sbatch command are:

-D path or –chdir=path   Specifies the working directory for the job. If not set, then the working directory is the current directory.

-e path/file or –error=path/file

-o path/file or –output=path/file    The names of the error (stderr) and standard output (stdout) files are given. By default, both outputs are merged into one slurm-<job_id>.out file in the current directory.

–mail-type=NONE,FAIL,BEGIN,END,ALL etc.   Events for sending notifications by e-mail: NONE – do not send notifications, FAIL – in case of abnormal termination of the task, BEGIN – at the moment of task start, END – at the moment of task completion, n – do not send notifications. You can specify multiple events separated by commas.

–mail-user=e-mail Notification recipient address. The default is the task owner.

-J name or –job-name=name  Specifies the name of the task.

-p queue or  –partition=queue

-n N or –ntasks=N Requests N processes for a task.

-N N or –nodes=N Requests N compute nodes for a task.

–nodes=N  –ntasks-per-node=M  Requests N compute nodes, and M processes on each node.

–cpus-per-task=N  Additionally requests N processor cores per process. The default is one core per process.

–mem=size Requests the required memory on each node. The size is specified using an integer followed by a suffix: K, M, G. For example, –mem=16G will request 16 GB of memory on each node.

-t time or –time=time   Limits the maximum task execution time. After this time, the program will end. The value is specified in minutes, or in one of the formats MM:SS, HH:MM:SS, DD-HH. The default value is 1 hour.

-C list or –constraint=list  Specifies additional restrictions on allocated nodes. The list can contain several elements separated by commas.

Environment variables set by Slurm:

SLURM_SUBMIT_DIR The directory where the user was at the time the task was submitted to the queue.

SLURM_JOB_ID The unique number of the task.

SLURMD_NODENAME The current node on which the script is running.

SLURM_NTASKS The number of dedicated processor cores.

The most commonly used SLURM commands are:

sbatch, srun – to send a job

scancel – to cancel the task

Informational:

sinfo – reports on the status of sections and nodes;

sstat – reports about job resources;

squeue – about the state of jobs or stages of a job 

The squeue -u user command will only show user jobs. The current state of the job is marked in the ST column.

PD – the job is in the queue, waiting for the release of resources.

R – The job is currently running.

The NODELIST column lists the nodes allocated to the task.

With squeue -l you can also see the requested time for each job, and with squeue –start you can get the expected start time for a task.

To view a list of users who can use queues, you can use the command:  sacctmgr show users

Use “man command” for detailed description.

Example:

#!/bin/bash

#SBATCH –job-name simple

#SBATCH –nodes=1

#SBATCH –time=02:00

echo “Start date: $(date)”

pwd

echo “End date: $(date)”

Sending a task:

sbatch simple.sh

Lines beginning with #SBATCH contain options for the sbatch command. You can also specify these options explicitly if you use the command line to run the job:

sbatch –job-name simple –nodes=1 –time=5:00 simple.sh