What is a scheduler?: Difference between revisions

Jump to navigation Jump to search
Marked this version for translation
No edit summary
(Marked this version for translation)
Line 2: Line 2:
<translate>
<translate>


== What's a job? ==
== What's a job? == <!--T:1-->
On computers we are most often familiar with graphical user interfaces (GUIs). There are windows, menus, buttons; we click here and there and the system responds. On Compute Canada servers the environment is different. To begin with, you control it by typing, not clicking. This is called a [[Linux introduction|command line interface]]. Furthermore, a program you would like to run may not begin immediately, but may instead be put in a waiting list. When the necessary CPU cores are available it will begin, otherwise jobs would interfere with each other leading to performance loss.  
On computers we are most often familiar with graphical user interfaces (GUIs). There are windows, menus, buttons; we click here and there and the system responds. On Compute Canada servers the environment is different. To begin with, you control it by typing, not clicking. This is called a [[Linux introduction|command line interface]]. Furthermore, a program you would like to run may not begin immediately, but may instead be put in a waiting list. When the necessary CPU cores are available it will begin, otherwise jobs would interfere with each other leading to performance loss.  


<!--T:2-->
You prepare a small text file called a ''job script'' that basically says what program to run, where to get the input, and where to put the output. You ''submit'' this job script to a piece of software called the ''scheduler'' which decides when and where it will run. Once the job has finished you can retrieve the results of the calculation. Normally there is no interaction between you and the program while the job is running, although you can check on its progress if you wish.
You prepare a small text file called a ''job script'' that basically says what program to run, where to get the input, and where to put the output. You ''submit'' this job script to a piece of software called the ''scheduler'' which decides when and where it will run. Once the job has finished you can retrieve the results of the calculation. Normally there is no interaction between you and the program while the job is running, although you can check on its progress if you wish.


<!--T:3-->
Here's a very simple job script:
Here's a very simple job script:
{{File
{{File
Line 19: Line 21:
It runs the programs <code>echo</code> and <code>sleep</code>, there is no input, and the output will go to a default location. Lines starting with <code>#SBATCH</code> are directives to the scheduler, telling it things about what the job needs to run. This job, for example, only needs one minute of run time (00:01:00).
It runs the programs <code>echo</code> and <code>sleep</code>, there is no input, and the output will go to a default location. Lines starting with <code>#SBATCH</code> are directives to the scheduler, telling it things about what the job needs to run. This job, for example, only needs one minute of run time (00:01:00).


== The job scheduler ==  
== The job scheduler == <!--T:4-->
The job scheduler is a piece of software with multiple responsibilities. It must  
The job scheduler is a piece of software with multiple responsibilities. It must  
* maintain a database of jobs,  
* maintain a database of jobs,  
Line 28: Line 30:
* clean up after each job finishes.
* clean up after each job finishes.


<!--T:5-->
On Compute Canada clusters, these responsibilities are handled by the [https://en.wikipedia.org/wiki/Slurm_Workload_Manager Slurm Workload Manager]. All the examples and syntax shown on this page are for Slurm.
On Compute Canada clusters, these responsibilities are handled by the [https://en.wikipedia.org/wiki/Slurm_Workload_Manager Slurm Workload Manager]. All the examples and syntax shown on this page are for Slurm.


== Requesting resources ==
== Requesting resources == <!--T:6-->
You use the job script to ask for the resources needed to run your calculation. Among the resources associated with a job are ''time'' and ''number of processors''. In the example above, the time requested is one minute and there will be one processor allocated by default since no specific number is given.  We describe below other types of requests such as multiple processors, memory capacity and special processors such as [https://en.wikipedia.org/wiki/General-purpose_computing_on_graphics_processing_units GPUs].
You use the job script to ask for the resources needed to run your calculation. Among the resources associated with a job are ''time'' and ''number of processors''. In the example above, the time requested is one minute and there will be one processor allocated by default since no specific number is given.  We describe below other types of requests such as multiple processors, memory capacity and special processors such as [https://en.wikipedia.org/wiki/General-purpose_computing_on_graphics_processing_units GPUs].


<!--T:7-->
It is important to specify those parameters well. If you ask for less than the calculation needs, the job will be killed for exceeding the requested time or memory limit. If you ask for more than it needs, the job may wait longer than necessary before it starts, and once running it will needlessly prevent others from using those resources.
It is important to specify those parameters well. If you ask for less than the calculation needs, the job will be killed for exceeding the requested time or memory limit. If you ask for more than it needs, the job may wait longer than necessary before it starts, and once running it will needlessly prevent others from using those resources.


==A basic SLURM job==  
==A basic SLURM job== <!--T:8-->


<!--T:9-->
We can submit the job script <code>simple_job.sh</code> shown above with [https://slurm.schedmd.com/sbatch.html sbatch]:
We can submit the job script <code>simple_job.sh</code> shown above with [https://slurm.schedmd.com/sbatch.html sbatch]:
<source lang="bash">
<source lang="bash">
Line 48: Line 53:
</source>
</source>


<!--T:10-->
Look at the ST column in the output of [[Running_jobs#Monitoring_jobs | squeue]] to determine the status of your jobs. The two most common states are "PD" for "pending" or "R" for "running". When the job has finished it no longer appears in the <code>squeue</code> output.
Look at the ST column in the output of [[Running_jobs#Monitoring_jobs | squeue]] to determine the status of your jobs. The two most common states are "PD" for "pending" or "R" for "running". When the job has finished it no longer appears in the <code>squeue</code> output.


<!--T:11-->
Notice that each job is assigned a "job ID", a unique identification number printed when you submit the job --- 1234 in this example. You can have more than one job in the system at a time, and the ID number can be used to distinguish them even if they have the same name. And finally, because we didn't specify anywhere else to put it the output is placed in a file named with the same job ID number, <code>slurm&#8209;1234.out</code>.
Notice that each job is assigned a "job ID", a unique identification number printed when you submit the job --- 1234 in this example. You can have more than one job in the system at a time, and the ID number can be used to distinguish them even if they have the same name. And finally, because we didn't specify anywhere else to put it the output is placed in a file named with the same job ID number, <code>slurm&#8209;1234.out</code>.


<!--T:12-->
You can also specify options to <code>sbatch</code> on the command line. So for example,
You can also specify options to <code>sbatch</code> on the command line. So for example,
  [someuser@host ~]$ sbatch --time=00:30:00 simple_job.sh  
  [someuser@host ~]$ sbatch --time=00:30:00 simple_job.sh  
will change the time limit of the job to 30 minutes. Any option can be overridden in this way.
will change the time limit of the job to 30 minutes. Any option can be overridden in this way.


==Choosing where the output goes==  
==Choosing where the output goes== <!--T:13-->
If you want the output file to have a more distinctive name than <code>slurm&#8209;1234.out</code>, you can use <code>--output</code> to change it.
If you want the output file to have a more distinctive name than <code>slurm&#8209;1234.out</code>, you can use <code>--output</code> to change it.
The following script sets a ''job name'' which will appear in <code>squeue</code> output, and sends the output to a file prefixed with the job name and containing the job ID number.  
The following script sets a ''job name'' which will appear in <code>squeue</code> output, and sends the output to a file prefixed with the job name and containing the job ID number.  


<!--T:14-->
{{File
{{File
   |name=name_output.sh
   |name=name_output.sh
Line 71: Line 80:
}}
}}


<!--T:15-->
Error output will normally appear in the same file, just as it would if you were typing commands interactively. If you wish you can split the standard error channel (stderr) from the standard output channel (stdout) by specifying a file name with the <code>&#8209;e</code> option.
Error output will normally appear in the same file, just as it would if you were typing commands interactively. If you wish you can split the standard error channel (stderr) from the standard output channel (stdout) by specifying a file name with the <code>&#8209;e</code> option.


==Accounts and projects==  
==Accounts and projects== <!--T:16-->
Information about your job, like how long it waited, how long it ran, and how many cores it used, is recorded so we can monitor our quality of service and so we can report to our funders how their money is spent. Every job must have an associated ''account name'' corresponding to a Compute Canada [https://ccdb.computecanada.ca/me/faq#what_is_rap resource allocation project].  
Information about your job, like how long it waited, how long it ran, and how many cores it used, is recorded so we can monitor our quality of service and so we can report to our funders how their money is spent. Every job must have an associated ''account name'' corresponding to a Compute Canada [https://ccdb.computecanada.ca/me/faq#what_is_rap resource allocation project].  


  #SBATCH --account=def-user-ab
  <!--T:17-->
#SBATCH --account=def-user-ab


<!--T:18-->
If you try to submit a job with <code>sbatch</code> without supplying an account name, and one is needed, you will be shown a list of valid account names to chose from.
If you try to submit a job with <code>sbatch</code> without supplying an account name, and one is needed, you will be shown a list of valid account names to chose from.


</translate>
</translate>
Bureaucrats, cc_docs_admin, cc_staff
2,879

edits

Navigation menu