Tags:
create new tag
view all tags

Slurm

Starting in May 2019, we're testing our new Slurm setup. Slurm is similar to GridEngine: it manages a cluster, distributing user jobs in (hopefully) a fair and efficient way.

The concepts are comparable, but the syntax is not.

This page will hopefully grow organically. Feel free to make corrections and add your tips, tricks and insights.

Defaults

Some defaults:

  • There is one "partition" (like a "queue" in GridEngine). It is called "one" (suggestions welcome; it cannot be called "default").
  • Default runtime is 10 minutes.
  • Default memory is 10 GB.
  • By default, your job gets 1 GB of "scratch" local disk space in "$TMPDIR" (where TMPDIR=/scratch/$SLURM_JOB_ID).

Running jobs

You can run jobs using "srun" (interactively), "sbatch" (like qsub), or use "salloc" to allocate resources and then "srun" your commands in that allocation.

srun

srun will execute the command given, and wait for it to finish. Some examples:

  • srun sleep 60

  • srun -n 4 bash -c "hostname; stress -c 10". This will start 4 seperate "tasks", each getting 1 CPU (2 cores on each). Eight threads in total.

This is different from:

  • srun -c 4 bash -c "hostname; stress -c 10". This will start 1 task, getting 4 cores (2 CPU's, 2 cores on each).

To me, the number of tasks, CPU's and cores is sometimes slightly surprising. I guess it will make sense after a while...

You can also use srun to get an interactive shell on a compute node (like qlogin):

  • srun -n 2 --mem 5G --time 01:00:00 --pty bash

Or on a specific node:

  • srun -n 2 --mem 5G --time 01:00:00 --nodelist n0014 --pty bash

sbatch

sbatch is like qsub. Commandline options are similar to srun, and can be embedded in a script file:

#!/bin/bash

#SBATCH -t 00:05:00
#SBATCH --mem=20G
#SBATCH -o log.out
#SBATCH -e errlog.out
#SBATCH --mail-type=FAIL
#SBATCH --mail-user=youremail@some.where #Email to which notifications will be sent

env
echo "Hello World" 

salloc/srun

Quoting from the documentation:

The final mode of operation is to create a resource allocation and spawn job steps within that allocation. The salloc command is used to create a resource allocation and typically start a shell within that allocation. One or more job steps would typically be executed within that allocation using the srun command to launch the tasks. Finally the shell created by salloc would be terminated using the exit command.

Be very careful to use srun to run the commands within your allocation. Otherwise, the commands will run on the machine that you're logged in on! See:

# Allocate two compute nodes:
[mmarinus@hpcm05 ~]$ salloc -N 2
salloc: Pending job allocation 1635
salloc: job 1635 queued and waiting for resources
salloc: job 1635 has been allocated resources
salloc: Granted job allocation 1635
salloc: Waiting for resource configuration
salloc: Nodes n[0009-0010] are ready for job

# I got n0009 and n0010
[mmarinus@hpcm05 ~]$ srun hostname
n0009.compute.hpc
n0010.compute.hpc

# But this command just runs on the machine I started the salloc command from!
[mmarinus@hpcm05 ~]$ hostname
hpcm05.manage.hpc

# Even if you "srun" something, be careful where (e.g.) variable expansion is done:
[mmarinus@hpcm05 ~]$ srun echo "running on $(hostname)"
running on hpcm05.manage.hpc
running on hpcm05.manage.hpc

# Exit the allocation
[mmarinus@hpcm05 ~]$ exit
exit
salloc: Relinquishing job allocation 1635

Local (scratch) disk space

If your job benefits from (faster) local disk space (like "qsub -l tmpspace=xxx"), request it like this:

srun --gres=tmpspace:250M --pty bash

Of course, this works for all the commands. The scratch disk space will be made available in $TMPDIR (/scratch/$SLURM_JOB_ID) and will be erased automatically when your job is finished.

Using a GPU

Something like:

srun -n 12 --gres=tmpspace:10G --gpus-per-node=1 --time 24:00:00 --mem 100G --pty bash

will give you an interactive session with 1 GPU.

srun --gpus-per-node=RTX2080Ti:1 --pty bash

will request a specific type of GPU.

SGE versus SLURM

SGE vs. SLURM
qstat - squeue
qsub - sbatch
qdel - scancel
qlogin - srun --pty bash

examples :
submit job named 1.sh
sge = qsub 1.sh
=
slurm = sbatch 1.sh

Extra information :
Official Slurm Workload Manager documentation
Slurm Tutorials
SGE to SLURM conversion

-- Martin Marinus - 2019-05-07

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2019-06-13 - MartinMarinus
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback