User Tools

Site Tools


srun

srun

Runs an executable file. It is really intended to be used from within sbatch scripts. Used within a script, each invocation of srun starts a new job step (terminology you will see in the slurm documentation).

Used from a terminal, srun runs the job in the foreground (and blocks unless you use “&”).

If you use srun directly (in a login terminal) your job will end if you close your terminal or close your laptop, unless you redirect IO and disown the job. You can also use a “terminal multiplexer” like screen, tmux, or byobu. However, even if you take steps to protect against “hang-ups”, if the head node needs to be rebooted (to pick up kernel updates, for instance) that will terminate any jobs running through srun. A reboot of the head node will not affect jobs submitted using sbatch.

Examples

srun hostname

srun –pty bash -i

  • Runs an interactive shell on a compute node.
  • You can specify a specific node with -w node5 (for instance).
    • Will only run if there is a slot available on the node.

srun -n3 hostname (runs 3 tasks: copies of the program specified, may run on the same node)

srun -n30 hostname (runs 30 tasks, will run on multiple nodes since no node in that standard queue has as many as 30 cores)

srun -N3 hostname (runs on 3 different nodes)

Protecting against "Hang-Ups"

srun long-job > srun.out 2>&1 &
disown

But it's much better to use sbatch.

srun.txt · Last modified: 2021/03/01 11:14 by root