DOD SUPERCOMPUTING RESOURCE CENTER
550 Lipoa Parkway, Kihei, Maui, Hawai'i 96753 - Phone: (808) 879-5077
Guide to the PBS Queuing Sytem on Riptide
On large-scale computers, many users must share available resources. Because of this, you cannot just log on to one of these systems, upload your programs, and start running them. Essentially, your programs (called batch jobs) have to "get in line" and wait their turn. And, there is more than one of these lines (called queues) from which to choose. Some queues have a higher priority than others (like the express checkout at the grocery store). The queues available to you are determined by the projects that you are involved with.
The jobs in the queues are managed and controlled by a batch queuing system, without which, users could overload systems, resulting in tremendous performance degradation. The queuing system will run your job as soon as it can while still honoring the following:
We use the PBS Professional queuing system. The PBS module should be loaded automatically for you at login, allowing you access to the PBS commands.
Anatomy of a Batch Script
A batch script is simply a small text file that can be created with a text editor such as vi or notepad. You may create your own from scratch, or start with one of the sample batch scripts available in $SAMPLES_HOME. Although the specifics of a batch script will differ slightly from system to system, a basic set of components are always required, and a few components are just always good ideas. The basic components of a batch script must appear in the following order:
Note: PBS does not handle ^M characters well. Scripts created on a MS Windows system should be transferred to the HPC systems in ASCII mode, or else use dos2unix to convert the file before use.
Specify Your Shell
First of all, remember that your batch script is a script. It's a good idea to specify which shell your script is written in. Unless you specify otherwise, PBS will use your default login shell to run your script. To tell PBS which shell to use, start your script with a line similar to the following, where shell is either bash, sh, ksh, csh, or tcsh:
Required PBS Directives
The next block of your script will tell PBS about the resources that your job needs by including PBS directives. These directives are actually a special form of comment, beginning with "#PBS". As you might suspect, the # character tells the shell to ignore the line, but PBS reads these directives and uses them to set various values. IMPORTANT!! All PBS directives MUST come before the first line of executable code in your script, otherwise they will be ignored.
Every script must include directives for the following:
Number of Cores per Node
Before PBS can schedule your job, it needs to know how many cores per node are required. This is accomplished with the "ncpus" directive. In general this value is always set to the total number of cores on the node (16) and is included on the same line as "select" and "mpiprocs" directives.
Number of Nodes and Processes Per Node
Before PBS can schedule your job, it needs to know how many nodes you want. Before your job can be run, it will also need to know how many processes you want to run on each of those nodes. In general, you would specify one process per core, but you might want more or fewer processes depending on the programming model you are using.
Both the number of nodes and processes per node are specified using the same directive as follows, where N1 is the number of nodes you are requesting and N2 is the number of processes per node:
#PBS -l select=N1:ncpus=16:mpiprocs=N2
How Nodes Should Be Allocated
Some default behaviors in PBS have the potential to seriously impair the ability of your scripts to run in certain situations, and could impose restrictions on submitted jobs that might cause them to wait much longer in the queue than necessary. To prevent these situations from occurring, the following PBS directive is required in all batch scripts on Riptide:
#PBS -l place=scatter:excl
For an explanation of what this directive means, see the qsub man page.
How Long to Run
Next, PBS needs to know how long your job will run. For this, you will have to make an estimate. There are three things to keep in mind.
To specify how long your job will run, include the following directive:
#PBS -l walltime=HHH:MM:SS
Which Queue to Run In
Now, PBS needs to know which queue you want your job to run in. Your options here are determined by your project. Most users only have access to the debug, standard, interactive, and background queues. Other queues exist, but access to these queues is restricted to projects that have been granted special privileges due to urgency or importance, and they will not be discussed here. As their names suggest, the standard and debug queues should be used for normal day-to-day and debugging jobs. The background queue, however, is a bit special because although it has the lowest priority, jobs that run in this queue are not charged against your project allocation. Users may choose to run in the background queue for several reasons:
To see the list of queues available on the system, use the show_queues command. To specify the queue you want your job to run in, include the following directive:
#PBS -q queue_name
Your Project ID
PBS now needs to know which project ID to charge for your job. You can use the show_usage command to find the projects that are available to you and their associated project IDs. In the show_usage output, project IDs appear in the column labeled "Subproject." Note: Users with access to multiple projects should remember that the project they specify may limit their choice of queues.
To specify the Project ID for your job, include the following directive:
#PBS -A Project_ID
The Execution Block
Once the PBS directives have been supplied, the execution block may begin. This is the section of your script that contains the actual work to be done. A well written execution block will generally contain the following stages:
Submitting Your Job
Once your batch script is complete, you will need to submit it to PBS for execution using the qsub command. For example, if you have saved your script into a text file named run.pbs, you would type "qsub run.pbs".
Occasionally you may want to supply one or more directives directly on the qsub command line. Directives supplied in this way override the same directives if they are already included in your script. The syntax to supply directives on the command line is the same as within a script except that #PBS is not used. For example:
qsub -l walltime=HHH:MM:SS run.pbs
Job Management Commands
The table below contains commands for managing your jobs in PBS.
Optional PBS Directives
In addition to the required directives mentioned above, PBS has many other directives, but most users will only use a few of them. Some of the more useful optional directives are listed below.
Job Identification Directives
Job identification directives allow you to identify characteristics of your jobs. These directives are voluntary, but strongly encouraged. The following table contains some useful job identification directives.
The "-l application" directive allows you to identify the application being used by your job. This helps the program to accurately assess application usage and to ensure that adequate software licenses and appropriate software are purchased. To use this directive, add a line in the following form to your batch script:
#PBS -l application=application_name
The "-N" directive allows you to designate a name for your job. In addition to being easier to remember than a numeric job ID, the PBS environment variable, $PBS_JOBNAME, inherits this value and can be used instead of the job ID to create job-specific output directories. To use this directive, add a line in the following form to your batch script:
#PBS -N job_20
Job Environment Directives
Job environment directives allow you to control the environment in which your script will operate. The following table contains a few useful job environment directives.
Interactive Batch Shell
The "-I" directive allows you to request an interactive batch shell. Within that shell, you can perform normal Unix commands, including launching parallel jobs. To use "-I", append it to the end of your qsub request. You may also use the "-X" option to allow for X-Forwarding to run X-Windows-based Graphical interfaces on the compute node, such as the TotalView debugger. For example:
qsub -A Project_ID -q debug -l select=2:ncpus=16:mpiprocs=16 -l place=scatter:excl -l walltime=1:00:00 -X -I
Export All Variables
The "-V" directive tells PBS to export all of the environment variables from your login environment into your batch environment. To use this directive, add a line in the following form to your batch script:
Export Specific Variables
The "-v" directive tells PBS to export specific environment variables from your login environment into your batch environment. To use this directive, add a line in one of the following forms to your batch script:
#PBS -v DISPLAY
Using either of these methods, multiple comma-separated variables can be included. It is also possible to set values for variables exported in this way, as follows:
qsub -v my_variable=my_value, ...
Reporting directives allow you to control what happens to standard output and standard error messages generated by your script. They also allow you to specify e-mail options to be executed at the beginning and end of your job.
Redirecting Stdout and Stderr
By default, messages written to stdout and stderr are captured for you in files named x.ojob_id and x.ejob_id, respectively, where x is either the name of the script or the name specified with the "-N" directive, and job_id is the ID of the job. If you want to change this behavior, the "-o" and "-e" directives allow you to redirect stdout and stderr messages to different named files. The "-j" directive allows you to combine stdout and stderr into the same file.
Setting up E-mail Alerts
Many users want to be notified when their jobs begin and end. The "-m" directive makes this possible. If you use this directive, you will also need to supply the "-M" directive with one or more e-mail addresses to be used.
#PBS -m be #PBS -M firstname.lastname@example.org,email@example.com
Job Dependency Directives
Job dependency directives allow you to specify dependencies that your job may have on other jobs. This allows users to control the order jobs run in. These directives will generally take the following form:
#PBS -W depend=dependency_expression
where dependency_expression is a comma-delimited list of one or more dependencies, and each dependency is of the form:
where type is one of the directives listed below, and jobids is a colon-delimited list of one or more job IDs that your job is dependent upon.
For example, run a job after completion (success or failure) of job ID 1234:
#PBS -W depend=afterany:1234
Or, run a job after successful completion of job ID 1234:
#PBS -W depend=afterok:1234
For more information about job dependencies, see the qsub man page.
PBS Environment Variables
While there are many PBS environment variables, you only need to know a few important ones to get started using PBS. The table below lists the most important PBS environment variables and how you might generally use them.
The following additional PBS variables may be useful to some users.
Other Important Environment Variables
In addition to the PBS environment variables, the table below lists a few other variables which are not specifically associated with PBS. These variables are not generally required, but may be important depending on your job.
PBSPro batch script REQUIRED stanzas
Specifies requested wallclock time for job in hours:minutes:seconds
The project account number assigned by S/AAA
PBSPro batch script OPTIONAL stanzas
Specifies when you would like the output file to be created.
Specifies when you would like the output file to be created.
Specifies which queue you would like to run in.
## Nodes, Processors, CPUs (processors and CPUs should always match)
Maui High Performance Computing Center
Document URL: http://www.mhpcc.hpc.mil/doc/riptidePbsGuide.html
Page returned at 04:56, Thursday February 11, 2016 HST (GMT -10 hours)