2

What is the difference between using srun inside the launcher script and not using it? for example, some launcher scripts are:

#!/bin/bash -l
#SBATCH -N 1
#SBATCH --ntasks-per-node=1
#SBATCH --time=0-00:05:00
#SBATCH -p batch
#SBATCH --qos=normal

srun pythonscript.py

but others change the last line directly to the script

#!/bin/bash -l
#SBATCH -N 1
#SBATCH --ntasks-per-node=1
#SBATCH --time=0-00:05:00
#SBATCH -p batch
#SBATCH --qos=normal

./pythonscript.py
Marcelo Ruiz
  • 373
  • 3
  • 14

1 Answers1

-1

The srun command is used to execute a command/script on a cluster. It's an alternative to sbatch, which only submits the script, not executes it immediately. Both commands take a specification of where and how to execute: what queue, runtime, account, et cetera.

Using srun inside a script that was submitted with sbatch is somewhat pointless: when it's executed you are already on the allocated nodes, and then srun immediately executes the script. Which is the same as executing it without srun.

See also SLURM `srun` vs `sbatch` and their parameters

Victor Eijkhout
  • 5,088
  • 2
  • 22
  • 23
  • 2
    Using srun inside a script that was submitted with sbatch is not pointless. From [SLURM `srun` vs `sbatch` and their parameters](https://stackoverflow.com/questions/43767866/slurm-srun-vs-sbatch-and-their-parameters): If your program is a parallel MPI program, srun takes care of creating all the MPI processes. If not, srun will run your program as many times as specified by the --ntasks option. – nameiki Jan 03 '22 at 15:56