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

Lennart Karlsson Lennart.Karlsson at nsc.liu.se
Wed Apr 5 06:13:53 MDT 2006

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.)

On an Altix, the job might be able to ask questions about the size
of the surrounding cpuset. But the cpuset-2.0 implementation is not
yet implemented in Torque, as far as I know.

-- Lennart Karlsson <Lennart.Karlsson at nsc.liu.se>
   National Supercomputer Centre in Linkoping, Sweden

More information about the torqueusers mailing list