Example SLURM scripts¶
There are many possible configurations for how parallelism can be setup. Here are some example situations and corresponding script:
Example 1: A single task with many cores¶
This kind of setup is good for running programs that have built in parallelism (can use multiple cores).
1 2 3 4 5 6 7 8 | |
Example 2: Many tasks running over multiple nodes¶
This kind of setup will launch a total of 16 tasks (8 tasks per node, 2 nodes). A total of 32 CPU cores will be used (2 for each task), while memory is set to use a total of 16 GB (1 GB per task).
1 2 3 4 5 6 7 8 | |
Example 3: Run a single task many times¶
This kind of setup will create an array job (numbered 1-12) and will run them in parallel (up to 6 at a time). Each iteration of the array will have 1 task, requesting 2 CPU cores and 8 GB of memory. The array number of accessible using the $SLURM_ARRAY_TASK_ID variable.
This is useful when you want to perform the same computation on different inputs/parameters.
1 2 3 4 5 6 7 8 9 | |
Example 4: Simple task with logging¶
This is the same as example 1, but output is captured and saved into the files specified by “--out" and “--error".
1 2 3 4 5 6 7 8 9 10 | |
Example 5: Run job only after dependency finishes first¶
This is the same as example 1, but will only start after the dependency job (job number 1234) has successfully completed.
1 2 3 4 5 6 7 8 9 | |
Example 6: Run job on specified nodes and partitions¶
This is the same as example 1, but will only run of the “standard” partition and “bhri-hpcnce-01” node (multiple values can be given if they are comma separated).
1 2 3 4 5 6 7 8 9 10 | |