Last active
September 21, 2021 13:40
-
-
Save lkluft/ae8c4dedd4e1247f9c581338b5e25c6d to your computer and use it in GitHub Desktop.
Minimal working example of SLURM Job Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Normal job run (only one job and one task) | |
sbatch test.job | |
# Start 10 jobs at a time (create a log file each, but this can be tweaked). | |
# We will run 16 jobs (ID 1--16) but only four at a time. If you leave out the | |
# `%4` SLURM usually sets an upper limit per user (about 20 or so). | |
# More info: https://slurm.schedmd.com/job_array.html | |
job_id=$(sbatch --parsable --array=1-16%4 test.job) | |
# Start a "normal" job again, that will run after the last task in the array. | |
sbatch --dependency=afterok:$job_id test.job | |
squeue -u $USER # Check the SLURM queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/ksh | |
#SBATCH --account=highresmonsoon | |
#SBATCH --job-name=array-test | |
#SBATCH --partition=booster | |
#SBATCH --time=00:01:00 | |
#SBATCH --gres=gpu:4 | |
hostname | |
# The environment variable `SLURM_ARRAY_TASK_ID` is set to the current task id. | |
# It can be used to, for example, index a list or array. | |
echo $SLURM_ARRAY_TASK_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment