By default, ParallelTable will use all the processors available in a PC. Is there a way to set a limit to the number of processors used by ParallelTable? For example, suppose I am running a Mathematica Script which has a ParallelTable statement on a PC with 8 cores. I want to limit the number of cores used by the script to 4. How can I do this?

  • $\begingroup$ Have you tried setting the parallel kernels from Evaluation->Parallel Kernel configuration -> Parallel tab -> Manual setting $\endgroup$ Apr 9, 2015 at 15:59
  • $\begingroup$ @GordonCoale This is a Mathematica script, which will run with no graphical interface. $\endgroup$
    – becko
    Apr 10, 2015 at 12:09
  • 1
    $\begingroup$ Its worth noting that if you want to set this persistently then the you can do with code so via Unprotect[$ProcessorCount]; $ProcessorCount = 4; I would presume LaunchKernels is better for most use cases. $\endgroup$ Apr 10, 2015 at 13:21

2 Answers 2


Before evaluating ParallelTable just launch however many kernels you want to use:


By default ParallelTable and the other Parallel* functions call LaunchKernels[] which will launch whatever you have configured(default is essentially LaunchKernels[Min[$ProcessorCount, $MaxLicenseSubprocesses]]).


To demonstrate evaluation in parallel computing on different number of kernels

1)Default list of kernels run for parallel computing

 (*("<<`1` local kernels>>", 6]}*)

2) Run ParallelTable on all kernels:

ParallelTable[Pause[1]; f[i], {i, 6}] // AbsoluteTiming 

  (*{1.009058, {f[1], f[2], f[3], f[4], f[5], f[6]}}*)

This result demonstrates how Pause[1]is distributed on 6 kernels: Total 6 seconds of pause are executed on 6 Kernels in parallel resulting in 1 seconds of execution

3) Run ParallelTable on only two kernels:

ParallelTable[Pause[1]; f[i], {i, 6}] // AbsoluteTiming   

(*{KernelObject[37, "local"], KernelObject[38, "local"]}   *)
    (*{3.004172, {f[1], f[2], f[3], f[4], f[5], f[6]}}*)

This result demonstrates how Pause[1] is distributed on 2 kernels: Total 6 seconds of pause are executed on 2 Kernels in parallel resulting in 3 seconds of execution


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.