More about the srun, sbatch, and salloc commands
Page Contents
Related Topics
Flags for Slurm Command
All the commands, i.e. srun, sbatch, and salloc require a set of flags, the values that they can take are as follows:
--cluster
chip-cpuchip-gpu
--account
pi_<name of the principal investigator>
--partition (Refer to chip Partitions and Usage for more details.)
general201820212024(can only be accessed by contributing PIs)
--qos (refers to Quality of service. Refer to chip-cpu QOS Restrictions for more details.
--time (refers to the total amount of time the user wants to allocate for the job)
in HH:MM:SS
--mem (refers to the upper bound on the CPU memory the user needs for that job from that node)
the memory limit can be checked by concatenating the “free -h” command with the srun command for a particular node, and then the value should be a number representing the memory in MB.
--cpus-per-task (refers to the number of CPU cores needed by the user) - Optional
Defaults to 1 if the flag is not provided. Refer to Cluster Specifications for more details.
--ntasks (refers to the number of parallel tasks the user wants the job to run) - Optional
Defaults to 1 if the flag is not provided
--nodes (refers to the number of worker nodes needed by the user to split the task into) - Optional
Defaults to 1 if the flag is not provided. Refer to Cluster Specifications for more details.
--nodelist (refers to the specific node the user wants to run their jobs on) - Optional
--constraint (refers to some constraint specifying the one of many parameters on the compute node, such as the GPU cards on the node) - Optional
--gres (refers to generic resources, and is only needed for chip-gpu)
gpu:n, wherenrefers o the number of GPU cards needed by the user
--pty (refers to allocating a pseudo-terminal, for running an interactive session, and is only needed for the
sruncommand)$SHELL
Path to shell - ex:
/bin/bash,/bin/zsh, etc
srun
Using the srun command, a user can submit a slurm submission script to create job “steps” in a parallel job or launch processes interactively via the terminal. For running the srun commands on the cpu and the gpu, the section below highlights the key differences.
srun on chip-cpu
For running the srun command on the cpu, the following parameters are required:
--cluster, which should be set to
chip-cpu
--account, which should be set to
pi_<name of the principal investigator>
--partition (Refer to chip Partitions and Usage for more details.)
gpugpu-generalpi_YOURPINAME(Only available to contributing PI groups)
--qos
--time
--mem
--pty
Hence, it should look like the following:
srun --cluster=chip-cpu --account=pi_doit --partition=general --qos=normal --time=1:00:00 --mem=5000 --pty $SHELLsrun on chip-gpu
When running on the gpu, the parameters required are:
--cluster, which should be set to
chip-gpu
--account, which should be set to
pi_<name of the principal investigator>
--mem
--time
--gres
--pty
Hence, it should look like the following:
srun --cluster=chip-gpu --account=pi_doit --mem=5000 --time=1:00:00 --gres=gpu:1 --pty $SHELLWhen using the srun command, note that in addition to the --account, --mem, --time, and --pty flags,
to run a job on chip-cpu, the --cluster flag needs to be set to a value of chip-cpu, and the flags --partition and --qos and their values are to be included, while to run a job on chip-gpu, the --cluster flag needs to be set to a value of chip-gpu, and the flag --gres and its value is to be included.
sbatch
Using the sbatch command, a user can take a bash script as its input and execute a series of tasks using the compute resources. Functionally, it does the same thing as the srun command, but it does not let the user do so in an interactive way like the srun command does.
sbatch on chip-cpu
Create a file (ending with the extension .slurm) using your favorite text editor that should look like the following:
[user@chip ~]$ cat sbatchTest.slurm
#!/bin/bash
#SBATCH --cluster=chip-cpu
#SBATCH --mem=5000M
#SBATCH --time=01:00:00
#SBATCH --account=pi_doit
#SBATCH --partition=general
#SBATCH --qos=normal
module load Python
python test.py
[user@chip ~]$ sbatch sbatchTest.slurmAs shown above, after the file is created, run the sbatch command to submit the job to the cluster.
sbatch on chip-gpu
Create a file (ending with the extension .slurm) using your favorite text editor that should look like the following:
[user@chip ~]$ cat sbatchTest.slurm
#!/bin/bash
#SBATCH --cluster=chip-gpu
#SBATCH --mem=5000M
#SBATCH --time=01:00:00
#SBATCH --account=pi_doit
#SBATCH --gres=gpu:2
module load Python
python test.py
[user@chip ~]$ sbatch sbatchTest.slurmAs shown above, after the file is created, run the sbatch command to submit the job to the cluster.
When using the sbatch command, similar to the srun command, note that in addition to the --account, --mem, and --timeflags,
to run a job on chip-cpu, the --cluster flag needs to be set to a value of chip-cpu, and the flags --partition and --qos and their values are to be included, while to run a job on chip-gpu, the --cluster flag needs to be set to a value of chip-gpu, and the flag --gres and its value is to be included.
salloc
The salloc command can be used to allocate the specified computing resources to an user, and hence the usage is similar to that of srun but without the command the users needs to run once the resources have been allocated, e.g.
salloc --cluster=chip-cpu --account=pi_doit --partition=general --qos=normal --time=1:00:00 --mem=5000