Slurm Job Array Examples
Example Job Array
We will take this Slurm script script and modify it to run as a job array.
Each task in a job array will run the same script and print 'Hello!' and the job array task ID. We are going to do this by passing the job array task ID as a command line argument to the script. The script accepts the command line argument and prints 'Hello!' and the task ID passed to it.
Let's modify our basic script to look like:
Then we modify the Slurm file to look like below:
Note that in this case, we specified Slurm option #SBATCH --array=1-10 to run ten independent tasks in parallel. The maximum job array size is set to 512 on the Yens. Each task will generate a unique log file hello-[jobID]-[taskID].out so we can look at those and see if any of the tasks failed.
Submit Job Array to Scheduler
We can now submit our hello-parallel.slurm script to the Slurm scheduler to run the job array. It will launch all ten tasks at the same time (some might sit in the queue while others are going to run right away). To submit, run:
Terminal Commandsbatch hello-parallel.slurm
Monitor your jobs with watch squeue -u USER where USER is your SUNet ID. Check which job array tasks failed.
Rerun those by setting --array= only to failed indices.