Limit the number of running jobs in SLURM

后端 未结 4 1185
粉色の甜心
粉色の甜心 2020-12-16 17:13

I am queuing multiple jobs in SLURM. Can I limit the number of parallel running jobs in slurm?

Thanks in advance!

4条回答
  •  眼角桃花
    2020-12-16 17:40

    According to SLURM documentation, --array=0-15%4 (- sign and not :) will limit the number of simultaneously running tasks from this job array to 4

    I wrote test.sbatch:

    #!/bin/bash
    # test.sbatch
    #
    #SBATCH -J a
    #SBATCH -p campus
    #SBATCH -c 1
    #SBATCH -o %A_%a.output
    
    mkdir test${SLURM_ARRAY_TASK_ID}
    
    # sleep for up to 10 minutes to see them running in squeue and 
    # different times to check that the number of parallel jobs remain constant
    RANGE=600; number=$RANDOM; let "number %= $RANGE"; echo "$number"
    
    sleep $number
    

    and run it with sbatch --array=1-15%4 test.sbatch

    Jobs run as expected (always 4 in parallel) and just create directories and kept running for $number seconds.

    Appreciate comments and suggestions.

提交回复
热议问题