Why is $ProcessorCount different than the selected number of cores in PBS? By using ParallelTable and submitting my Mathematica code to a cluster, I noticed that it was enhancing the speed even when I selected a single core in a single node, comparing to the use of standard Table. Verifying the number of cores using $ProcessorCount, I got 16.

For selecting the number of cores I have submitted a bash file in terminal (already logged in SSH) using

qsub -I run_inter.sh


The file "run_inter.sh" contains

#!/bin/sh
#PBS -l walltime=10:00:00

#PBS -q par32
#PBS -l nodes=1:ppn=1


where "par32" is a machine with 32GB of RAM.

Is there any reason for Mathematica to ignore the specification of core number and use 16 anyway?

1 Answer

Your PBS specifications do not get sent to Mathematica. PBS doesn't control Mathematica. Your job is being run on a machine with 16 cores and Mathematica sees this, hence the result of $ProcessorCount. To limit Mathematica to a single core, add the following lines to your script SetSystemOptions["MKLThreads" -> 1] SetSystemOptions["ParallelOptions" -> "ParallelThreadNumber" -> 1]  This will not affect the result of $ProcessorCount

• Thank you. So, the option nodes= :ppn=  is useless when using Mathematica? How can I choose the number of nodes in the cluster? – fcpenha Sep 24 '13 at 23:11
• Its a two step process, #PBS -l nodes=1:ppn=1 tells your cluster that you intend to use one core and SetSystemOptions["MKLThreads" -> 1] SetSystemOptions["ParallelOptions" -> "ParallelThreadNumber" -> 1] ensures that you really do only use one core – WalkingRandomly Sep 25 '13 at 0:11
• You can control the number of kernels used in ParallelTable using LaunchKernels[]. So, LaunchKernels[4] uses four for example. – WalkingRandomly Sep 25 '13 at 0:13
• But, for example, that machine has nodes with 16 cores each. If I want to use 20 cores (10 for each node), I should use #PBS -l nodes=2:ppn=10 plus what? LaunchKernels[20] ? – fcpenha Sep 25 '13 at 1:46
• If you want to launch kernels across nodes, you or your sysadmin has a lot more work to do. Wolfram lightweight grid may be of use wolfram.com/lightweight-grid-manager but might be a lot of work to make it play nicely with PBS. I'm not sure...never done it. Life will be much easier for you if you just batch your work into several independent 16 core jobs – WalkingRandomly Sep 25 '13 at 8:22