Home > database >  How to correctly submit an array of jobs using slurm
How to correctly submit an array of jobs using slurm

Time:07-13

I'm trying to submit an array of jobs using slurm, but it's not working as I expected. My bash script is test.sh:

#!/bin/bash                                                                                                      
#SBATCH --nodes=1                                                                                                
#SBATCH --ntasks=1                                                                                               
#SBATCH --cpus-per-task=1                                                                                        
#SBATCH --mem=10G                                                                                                
#SBATCH --account=myaccount                                                                                        
#SBATCH --partition=partition                                                                                      
#SBATCH --time=10:00:00                                                                                          
###Array setup here                                                                                              
#SBATCH --array=1-6                                                                                              
#SBATCH --output=test_%a.out                                                                                   

echo TEST MESSAGE 1
echo $SLURM_ARRAY_TASK_ID

python test.py

The test.py code:

print('TEST MESSAGE 2')

I then submitted this job by doing:

sbatch --wrap="bash test.sh"

I'm not even sure if this is how I should run it. Because there are already SBATCH commands in the bash script, should I just be running bash test.sh?

I was expecting that 5 jobs would be submitted and that $SLURM_ARRAY_TASK_ID would increase incrementally, but that's not happening. Just one job is submitting and the output is:

TEST MESSAGE 1

TEST MESSAGE 2

So the $SLURM_ARRAY_TASK_ID never get's printed and seems to be the problem. Can anyone tell me what I'm doing wrong?

CodePudding user response:

You just need to submit the script with sbatch test.sh. Using --wrap in the way you've done it just runs test.sh as a simple Bash script, so none of the Slurm-specific parts are used.

  • Related