Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

Using srun to create multiple jobs steps

You can use srun  to start multiple job steps concurrently on a single node, e.g. if your job is not big enough to fill a whole node. There are a few details to follow:

  • By default, the srun command gets exclusive access to all resources of the job allocation and uses all tasks
    • you therefore need to limit srun to only use part of the allocation
    • this includes implicitly granted resources, i.e. memory and GPUs
    • the --exact flag is needed.
    • if running non-mpi programs, use the -c option to denote the number of cores, each process should have access to
  • srun  waits for the program to finish, so you need to start concurrent processes in the background
  • Good default memory per cpu values (without hyperthreading) are usually are:


    standard96large96huge96medium40large40/gpu
    --mem-per-cpu

    3770M

    7781M15854M

    4525M

    19075M


Examples

Codeblock
languagebash
titleFour concurrent Programs
linenumberstrue
#!/bin/bash
#SBATCH -p standard96
#SBATCH -t 06:00:00
#SBATCH -N 1

srun --exact -n1 -c 10 --mem-per-cpu 3770M  ./program1 &
srun --exact -n1 -c 80 --mem-per-cpu 3770M  ./program2 &
srun --exact -n1 -c 6 --mem-per-cpu 3770M  ./program3 &
wait

...

Codeblock
languagebash
titleRun a single GPU program four times concurrently
linenumberstrue
#!/bin/bash
#SBATCH -p gpu
#SBATCH -t 12:00:00
#SBATCH -N 1

srun --exact -n1 -c 10 -G1 --mem-per-cpu 19075M  ./single-gpu-program &
srun --exact -n1 -c 10 -G1 --mem-per-cpu 19075M  ./single-gpu-program &
srun --exact -n1 -c 10 -G1 --mem-per-cpu 19075M  ./single-gpu-program &
srun --exact -n1 -c 10 -G1 --mem-per-cpu 19075M  ./single-gpu-program &
wait

Using the Linux parallel command to run a large number of tasks

If you have to run many nearly identical but small tasks (single-core, little memory) you can try to use the Linux parallel command. To use this approach you first need to write a bash-shell script, e.g. task.sh, which executes a single task. As an example we will use the following script:

...

Codeblock
$ sbatch parallel_job.sh

Looping over two arrays

You can use parallel  to loop over multiple arrays. The --xapply  option controls, if all permuatations are used or not:

...