You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/hpc/13_tutorial_intro_hpc/04_scheduler_fundamentals.mdx
+59-6Lines changed: 59 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,9 +64,9 @@ To submit this task to the scheduler, we use the `sbatch` command. This creates
64
64
Submitted batch job 137860
65
65
```
66
66
67
-
And that’s all we need to do to submit a job. Our work is done – now the scheduler takes over and tries to run the job for us. While the job is waiting to run, it goes into a list of jobs called the `queue`. To check on our job’s status, we check the queue using the command `squeue -u NetID`.
67
+
And that’s all we need to do to submit a job. Our work is done – now the scheduler takes over and tries to run the job for us. While the job is waiting to run, it goes into a list of jobs called the `queue`. To check on our job’s status, we check the queue using the command `squeue --me`.
68
68
```bash
69
-
[NetID@log-1 ~]$ squeue -u NetID
69
+
[NetID@log-1 ~]$ squeue --me
70
70
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
71
71
137860 normal example- usernm R 0:02 1 c5-59
72
72
```
@@ -93,7 +93,7 @@ hostname
93
93
Submit the job and monitor its status:
94
94
```bash
95
95
[NetID@log-1 ~]$ sbatch example-job.sh
96
-
[NetID@log-1 ~]$ squeue -u NetID
96
+
[NetID@log-1 ~]$ squeue --me
97
97
JOBID ACCOUNT NAME ST REASON START_TIME TIME TIME_LEFT NODES CPUS
Submit the job and wait for it to finish. Once it is has finished, check the log file.
157
157
```bash
158
158
[NetID@log-1 ~]$ sbatch example-job.sh
159
-
[NetID@log-1 ~]$ squeue -u NetID
159
+
[NetID@log-1 ~]$ squeue --me
160
160
cat slurm-38193.out
161
161
This job is running on: c1-14
162
162
slurmstepd: error: *** JOB 38193 ON gra533 CANCELLED AT 2017-07-02T16:35:48
@@ -169,7 +169,7 @@ Our job was killed for exceeding the amount of resources it requested. Although
169
169
Sometimes we’ll make a mistake and need to cancel a job. This can be done with the `scancel` command. Let’s submit a job and then cancel it using its job number (remember to change the walltime so that it runs long enough for you to cancel it before it is killed!).
170
170
```bash
171
171
[NetID@log-1 ~]$ sbatch example-job.sh
172
-
[NetID@log-1 ~]$ squeue -u NetID
172
+
[NetID@log-1 ~]$ squeue --me
173
173
Submitted batch job 38759
174
174
175
175
JOBID ACCOUNT NAME ST REASON TIME TIME_LEFT NODES CPUS
@@ -179,7 +179,7 @@ Now cancel the job with its job number (printed in your terminal). A clean retur
179
179
```bash
180
180
[NetID@log-1 ~]$ scancel 38759
181
181
# It might take a minute for the job to disappear from the queue...
182
-
[NetID@log-1 ~]$ squeue -u NetID
182
+
[NetID@log-1 ~]$ squeue --me
183
183
JOBID USER ACCOUNT NAME ST REASON START_TIME TIME TIME_LEFT NODES CPUS
184
184
```
185
185
@@ -189,6 +189,59 @@ We can also cancel all of our jobs at once using the `-u` option. This will dele
189
189
Try submitting multiple jobs and then cancelling them all with `scancel -u NetID`.
190
190
:::
191
191
192
+
## Job Arrays
193
+
> Job arrays offer a mechanism for submitting and managing collections of similar jobs quickly and easily, useful for repetitive workloads that follow a common job pattern. This greatly improves overall performance, since job arrays with millions of tasks can be submitted in milliseconds (subject to configured size limits) and the scheduler can quickly identify cases when no more array tasks are eligible to start.<br />
As stated above, you can have a single sbatch job submit multiple jobs by using Job Arrays. This example shows how you can run the same python file with a range of input parameters from a single sbatch file.
198
+
199
+
Copy the following code into a file named `run_array.sh`:
print(f"Starting training with learning rate: {current_lr}")
231
+
232
+
if __name__ == '__main__':
233
+
main()
234
+
235
+
```
236
+
237
+
Place those files in the same directory and then submit with the command:
238
+
```bash
239
+
sbatch run_array.sh
240
+
```
241
+
When they're done running you should find 5 files in your directory named `array_job_id.out` where the `job_id` will be a long integer. Each of those files will contain one of the values in the learning rate array in `run_array.sh`
242
+
243
+
Please see the [Slurm Documentation](https://slurm.schedmd.com/job_array.html) for more details.
244
+
192
245
## Other Types of Jobs
193
246
Up to this point, we’ve focused on running jobs in batch mode. Slurm also provides the ability to start an interactive session.
0 commit comments