-1

How do I run setup code in a SLURM sbatch script? Can I just use two srun lines?

Are these two srun lines guaranteed to run on the same node, without cleanup inbetween?

#!/bin/bash

# Parameters
#SBATCH ...

# setup
srun cp /nfs/data $TMPDIR

# job
srun a.out $TMPDIR
Nils Werner
  • 34,832
  • 7
  • 76
  • 98

1 Answers1

0

The srun command will start as many instances of the command as specified with the --ntasks parameter. It is typically used with MPI programs and programs that run embarrassingly parallel workloads.

A command like srun cp ... only makes sense in the case multiple nodes are requested and only one task is running per node, so with for instance --nodes=N or --ntasks=N --ntasks-per-node=1 or a similar combination. It can be used to copy files from a network filesystem to a local filesystem.

If there is only one node and multiple tasks, the srun could cause problems by concurrently trying to write to the same file.

If there is only one task, then the srun are not really needed (except if you want to use sstat to monitor them).

In any case, consecutive srun's are run on the same sets of nodes without cleaning.

damienfrancois
  • 52,978
  • 9
  • 96
  • 110