[torqueusers] How to get number of allocated CPUs within job script?

Garrick Staples garrick at usc.edu
Wed Apr 5 10:03:59 MDT 2006

On Wed, Apr 05, 2006 at 02:13:53PM +0200, Lennart Karlsson alleged:
> We run Torque and Moab on a 64 processor Altix system, i.e.
> one node containing 64 processors.
> Within a job script you want to know how many processors was
> allocated to the job by Moab.
> If you are lucky, you can count the number of lines in the file
> $PBS_NODEFILE, but not always, e.g. when you use the ncpus
> specification in your qsub command.
> It seems clumsy to run "showres" to fetch this information... Is
> there a better way?
> Perhaps a new $PBS_ variable is needed? (Does Torque know the number
> of processors? It does not disclose that information in the
> 'qstat -f' output.)

Nope, maui may be reserving multiple CPUs, but it isn't telling TORQUE
about it.  

As far as TORQUE is concerned, the virtual nodes in "exec_host", which
are all written to $PBS_NODEFILE, defines the resources allocated to the

This is only a problem with ncpus.  If you use nodes, counting the
number of lines in $PBS_NODEFILE is reliable.

Garrick Staples, Linux/HPCC Administrator
University of Southern California
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.supercluster.org/pipermail/torqueusers/attachments/20060405/3add302e/attachment-0001.bin

More information about the torqueusers mailing list