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

#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 1


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

  • $\begingroup$ Thank you. So, the option nodes= :ppn= is useless when using Mathematica? How can I choose the number of nodes in the cluster? $\endgroup$
    – fcpenha
    Sep 24, 2013 at 23:11
  • $\begingroup$ 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 $\endgroup$ Sep 25, 2013 at 0:11
  • $\begingroup$ You can control the number of kernels used in ParallelTable using LaunchKernels[]. So, LaunchKernels[4] uses four for example. $\endgroup$ Sep 25, 2013 at 0:13
  • $\begingroup$ 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] ? $\endgroup$
    – fcpenha
    Sep 25, 2013 at 1:46
  • 1
    $\begingroup$ 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 $\endgroup$ Sep 25, 2013 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.