PBS Professional And OpenPBS
NVIDIA Base Command Manager works with PBS Professional and OpenPBS, which are the modern editions of the original Portable Batch System (PBS) software. The original PBS software was a workload management and job scheduling system to manage computing resources, and was originally developed at NASA in the 1990s.
In this manual, PBS is used as a shorter form to refer to both the modern editions.
PBS job scripts are used to submit and execute jobs. The user puts values into a job script for the resources being requested, such as the number of processors to be used, the memory to be used, or number of nodes required. Other values are also set for the runtime parameters and application-specific variables.
The steps for running a job through a PBS job script are:
-
Creating an application to be run via the job script
-
Creating the job script, adding directives, applications, runtime parameters, and application-specific variables to the script
-
Submitting the script to the workload management system
This chapter covers the using the workload managers and job scripts with the PBS variants so that users can get a basic understanding of how they are used, and can get started with typical cluster usage.
In this chapter:
-
section 7.1 covers the components of a job script and job script examples
-
section 7.2.1 covers submitting, monitoring, and deleting a job with a job script
More on using PBS is to be found in the PBS Professional Guides, which can be accessed from: https://community.altair.com/community?id=altair_product_documentation.
7.1 Components Of A Job Script
To use PBS, a batch job script is created by the user. The job script is a shell script containing the set of commands that the user wants to run. It also contains the resource requirement directives and other specifications for the job. After preparation, the job script is submitted to the workload manager using the qsub command. The workload manager then tries to make the job run according to the job script specifications.
A job script can be resubmitted with different parameters (e.g. different sets of data or variables).
7.1.1 Sample Script Structure
A job script in PBS has a structure illustrated by the following basic example:
Example
The first line is the standard “shebang” line used for scripts.
The lines that start with #PBS are PBS directive lines, described shortly in section 7.1.2.
The last two lines are an example of setting any remaining options or configuration settings up, so that the script can run. In this case, a change to the directory myprogs is made, and then the executable myprog is run, with arguments a b c. The line that runs the program is called the executable line (section 7.1.3).
To run the executable file in the executable line in parallel, the job launcher mpirun is placed immediately before the executable file. The number of nodes the parallel job is to run on is assumed to have been specified in the PBS directives.
7.1.2 Directives
7.1.2.1 Job Script Directives And qsub Options
A job script typically has several configurable values called job script directives, set with job script directive lines. These are lines that start with a “#PBS”. Any directive lines beyond the first executable line are ignored.
The lines are comments as far as the shell is concerned because they start with a “#”. However, at the same time the lines are special commands when the job script is processed by the qsub command. The difference is illustrated by the following:
-
The following shell comment is only a comment for a job script processed by
qsub: -
The following shell comment is also a job script directive when processed by
qsub:
Job script directive lines with the #PBS part removed are the same as options applied to the qsub command, so a look at the man pages of qsub describes the possible directives and how they are used. If there is both a job script directive and a qsub command option set for the same item, then the qsub option takes precedence.
Since the job script file is a shell script, the shell interpreter used can be changed to another shell interpreter by modifying the first line (the “#!” line) to the preferred shell. Any shell specified by the first line can also be overridden by using the “#PBS -S” directive to set the shell path.
7.1.2.2 Walltime Directive
The workload manager typically has default walltime limits per queue with a value limit set by the administrator. The user can set a walltime limit for the job by setting the ”#PBS -l walltime” directive to a specific time. The time specified is the maximum time that the user expects the job should run for, and it allows the workload manager to work out an optimum time to run the job. The job can then run sooner than it would by default.
If the walltime limit is exceeded by a job, then the job is stopped, and an error message in the following format is displayed:
Here, <running time> is the time that the job actually took to run after it ran, while <set time> is the time that the user set as the walltime resource limit.
If there is no default walltime set by the cluster administrator, and if the user submits a job with no walltime set too, then the job only runs when all jobs with a walltime have made room. So to avoid waiting a very long time, and to experience a reasonably consistent behavior on different clusters, the user really should set a walltime.
7.1.2.3 Resource List Directives
Resource list directives specify arguments to the -l directive of the job script, and allow users to specify values to use instead of the system defaults.
For example, in the sample script structure earlier, a job walltime of one hour and a memory space of at least 500MB are requested (the script requires the size of the space be spelled in lower case, so “500mb” is used).
If a requested resource list value exceeds what is available, the job is queued until resources become available.
For example, if nodes only have 2000MB to spare and 4000MB is requested, then the job is queued indefinitely, and it is up to the user to fix the problem.
Resource list directives also allow, for example, the number of nodes (-l select=2:) and the number of processor cores for each node, ncpus, to be specified. If no value is specified, then the default is 1 node, and 1 core per node (ncpus=1).
As an aside: To avoid specifying ncpus with a directive, the default value for ncpu can be configured by the cluster administrator with the PBS qmgr configuration setting (section 7.11.1 of the Administrator Manual):
Example
A directive for a resource such as the wall time applies to the entire job. In PBS, such a resource is called a job-wide resource.
A collection of resources allocated to a job, but with the resources being requested from the same physical compute node, is called a chunk. A directive can be applied at chunk level with the select=chunk name option. Typically, an MPI job has one chunk per MPI process (rank).
Thus, requested resources can be job-wide only (for example, walltime), or chunk only (for example, ncpus). In a job, a resource cannot be used as chunk as well as job-wide—it can only be used as chunk (one or multiple chunks), or job-wide.
So, to run a job on 8 cores, the job-wide specification could be done with:
The preceding specification requests 8 CPU cores, and the cores can be anywhere on the cluster.
To run a job on one chunk, the chunk specification could be done with:
The preceding specification requests 8 CPU cores, and the cores must be on the same physical node.
Further examples of node resource specification are given in a table here.
7.1.2.4 Job Directives: Job Name, Logs, And IDs
If the name of the job script file is jobname, then by default the output and error streams are logged to jobname.o <number> and jobname.e <number> respectively, where <number> indicates the associated job number. The default paths for the logs can be changed by using the -o and -e directives respectively, while the base name (jobname here) can be changed using the -N directive.
Often, a user may simply merge both logs together into one of the two streams using the -j directive. Thus, in the preceding example, “-j oe” merges the logs to the output log path, while “-j eo” would merge it to error log path.
The job ID is an identifier based on the job number and the FQDN of the login node. For a login node called basecm10.cm.cluster, the job ID for a job number with the associated value <number> from earlier, would by default be <number>.basecm10.cm.cluster, but it can also simply be abbreviated to <number>.
7.1.2.5 Job Queues
Sending a job to a particular job queue is sometimes appropriate. An administrator may have set queues up so that some queues are for very long term jobs, or some queues are for users that require GPUs. Submitting a job to a particular queue <destination> is done by using the directive “#PBS -q <destination>”.
7.1.2.6 Directives Summary
Some useful job directives are illustrated in the following table:
Almost every qsub sets a job attribute, and has a corresponding PBS directive with the same syntax as the option. The man page for qsub and the man page for pbs_job_attributes explain this in detail.
7.1.2.7 Resource Request Examples
As PBS evolved, the specification for requesting nodes has changed. The form:
is deprecated, and automatically converted to:
The deprecated changes are described in detail the man page for pbs_resources, in the section on BACKWARD COMPATIBILITY.
Examples of requests for select= options are shown in the following table:
Some of the examples illustrate requests for GPU resource usage. GPUs and the CUDA utilities for NVIDIA are introduced in Chapter 8. GPU usage is treated by the workload manager like the attributes of a resource which the cluster administrator will have pre-configured according to local requirements.
For further details on resources, the man page for pbs_resources can be checked.
7.1.3 The Executable Line
In the job script structure (section 7.1.1), the executable line is launched with the job launcher command after the directives lines have been dealt with, and after any other shell commands have been carried out to set up the execution environment.
7.1.3.1 Using mpirun In The Executable Line
The mpirun command is used for executables compiled with MPI libraries. Executables that have not been compiled with MPI libraries, or which are launched without any specified number of nodes, run on a single free node chosen by the workload manager.
The executable line to run a program myprog that has been compiled with MPI libraries is run by placing the job-launcher command mpirun before it as follows:
7.1.4 Example Batch Submission Scripts
7.1.4.1 Node Availability
The following job script tests which out of 4 nodes requested with “-l nodes” are made available to the job in the workload manager:
Example
The directive specifying walltime means the script runs at most for 1 minute. The ${PBS_NODEFILE} array used by the script is created and appended with hosts by the queuing system. The script illustrates how the workload manager generates a ${PBS_NODEFILE} array based on the requested number of nodes, and which can be used in a job script to spawn child processes. When the script is submitted, the output from the log will look like:
This illustrates that the job starts up on a node, and that no more than the number of nodes that were asked for in the resource specification are provided.
The list of all nodes for a cluster can be found using the pbsnodes command (section 7.2.6).
7.1.4.2 Using InfiniBand
A sample PBS script for InfiniBand is:
In the preceding script, no machine file is needed, since it is automatically built by the workload manager and passed on to the mpirun parallel job launcher utility. The job is given a unique ID and run in parallel on the nodes based on the resource specification.
7.1.5 Links To PBS Resources
A number of useful links are:
-
The PBS Professional documentation pages, accessible from https://community.altair.com/community?id=altair_product_documentation.
-
The man pages for
qsub,pbs_resources, andpbs_job_attributes, for setting up job scripts. -
The community support pages for PBS Professional, accessible at https://community.altair.com/community?id=altair_community_home. Commercial support can be arranged for PBS Professional using https://www.altair.com/tailored-solutions.
-
The OpenPBS community pages, accessible from http://community.openpbs.org/.
7.2 Submitting A Job
7.2.1 Preliminaries: Loading The Modules Environment
To submit a job to the workload management system, the user must ensure that the following environment modules are loaded:
Users can pre-load particular environment modules as their default using the “module init*” commands (section 2.3.3).
7.2.2 Using qsub
The command qsub is used to submit jobs to the workload manager system. The command returns a unique job identifier, which is used to query and control the job and to identify output. The usage format of qsub and some useful options are listed here:
For example, a job script called mpirun.job with all the relevant directives set inside the script, may be submitted as follows:
Example
A job may be submitted to a specific queue testq as follows:
Example
The man page for qsub describes these and other options. The options correspond to PBS directives in job scripts (section 7.1.1). If a particular item is specified by a qsub option as well as by a PBS directive, then the qsub option takes precedence.
7.2.3 Job Output
By default, the output from the job script <scriptname> goes into the current working directory for PBS.
By default, error output is written to <scriptname>.e<jobid> and the application output is written to <scriptname>.o<jobid>, where <jobid> is a unique number that the workload manager allocates. Specific output and error files can be set using the -o and -e options respectively. The error and output files can usefully be concatenated into one file with the -j oe or -j eo options. More details on this can be found in the qsub man page.
7.2.4 Monitoring The Status Of A Job
To use the commands in this section, the appropriate workload manager module must be loaded:
7.2.4.1 qstat Basics
The main component is qstat, which has several options. In this example, the most frequently used options are discussed.
In PBS, the command “qstat -an” shows what jobs are currently submitted or running on the queuing system. An example output is:
The output shows the Job ID, the user who owns the job, the queue, the job name, the session ID for a running job, the number of nodes requested, the number of CPUs or tasks requested, the time requested (-l walltime), the job state (S) and the elapsed time. In this example, one job is seen to be running (R), and one is still queued (Q). The -n parameter causes nodes that are in use by a running job to display at the end of that line.
Possible job states include:
The command “qstat -q” shows what queues are available. In the following example, there is one job running in the testq queue and 4 are queued.
7.2.4.2 Viewing Job Details With qstat
With qstat -f the full output of the job is displayed. The output shows what the jobname is, where the error and output files are stored, and various other settings and variables.
7.2.5 Deleting A Job
An already submitted job can be deleted using the qdel command:
$ qdel <jobid>
Multiple space-separated job IDs can be specified.
7.2.6 Nodes According To PBS
The nodes that the workload manager knows about can be viewed using the pbsnodes command.
The following output is from a cluster made up of nodes with 4 physical cores, as indicated by the value of 4 for pcpus. If the node is available to run scripts, then its state is free or time-shared. When a node is used exclusively (section 8.5.2) by one script, the state is job-exclusive.
For PBS Professional the display resembles (some output elided):