Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
habrok:advanced_job_management:job_arrays [2020/12/22 10:07] – external edit 127.0.0.1 | habrok:advanced_job_management:job_arrays [2024/03/14 14:32] (current) – Minor formatting pedro | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Job arrays ====== | ====== Job arrays ====== | ||
- | Job arrays allow you to easily submit a whole bunch of very similar jobs with a single job script. All jobs need to have the same resource requirements. The job array allows you to define some range of numbers; the length of this range determines how many jobs will be submitted. Furthermore, | + | Job arrays allow you to easily submit a whole bunch of very similar jobs with a single job script. All jobs need to have the same resource requirements. The job array allows you to define some range of numbers; the length of this range determines how many jobs will be submitted. Furthermore, |
In order to create a job array, start by creating the job script that you would need to run just one instance of the job. For instance, consider the following job script for running R: | In order to create a job array, start by creating the job script that you would need to run just one instance of the job. For instance, consider the following job script for running R: | ||
Line 21: | Line 21: | ||
</ | </ | ||
\\ | \\ | ||
- | Then you can use "sbatch <name of job script>" | + | Then you can use '' |
===== Using ${SLURM_ARRAY_TASK_ID} ===== | ===== Using ${SLURM_ARRAY_TASK_ID} ===== | ||
Line 39: | Line 39: | ||
</ | </ | ||
\\ | \\ | ||
- | Here the variable ${SLURM_ARRAY_TASK_ID} will be replaced for each job by a value in the given range. | + | Here the variable |
===== More complex ranges ===== | ===== More complex ranges ===== | ||
Line 53: | Line 53: | ||
===== Even more complex cases ===== | ===== Even more complex cases ===== | ||
- | Suppose that you want to use this to pass input parameters to your program. If the input parameter takes a complex range of values, or if you need more than one parameter, the approach described above would probably not work. In this case you could put all your input parameter combinations in a file, where each combination is on a separate line. You can then use the $SLURM_ARRAY_TASK_ID variable to get the n-th line from the file, and pass that your program. For instance: | + | Suppose that you want to use this to pass input parameters to your program. If the input parameter takes a complex range of values, or if you need more than one parameter, the approach described above would probably not work. In this case you could put all your input parameter combinations in a file, where each combination is on a separate line. You can then use the '' |
< | < | ||
Line 64: | Line 64: | ||
</ | </ | ||
- | Alternatively, | + | Alternatively, |
< | < | ||
Line 76: | Line 76: | ||
===== Output and job information for job arrays ===== | ===== Output and job information for job arrays ===== | ||
- | A job array will get just one main job id, just like a regular job. However, the index values of the range will be used as suffix for the job id: < | + | A job array will get just one main job id, just like a regular job. However, the index values of the range will be used as suffix for the job id: < |
- | The same kind of job ids will also be used in the output of SLURM tools like squeue and sacct. The squeue command will usually try to combine the jobs in the array into a single line, e.g.: | + | The same kind of job ids will also be used in the output of SLURM tools like '' |
< | < | ||
Line 85: | Line 85: | ||
</ | </ | ||
\\ | \\ | ||
- | If you want to get each job of the array to appear on a separate line, you can pass the -r or —array option to squeue. | + | If you want to get each job of the array to appear on a separate line, you can pass the '' |
===== Cancelling job arrays ===== | ===== Cancelling job arrays ===== |