Sometimes, when Mathematica thinks it is needed, it automatically threads a computation on several cores, it can happen for NIntegrate or NDSolve for example.

I am going to use a shared workstation, so I cannot risk that my program uses all the cores: is there a way to limit the use of cores in this case? Something similar to LaunchKernels used for manual parallelization.

EDIT I have tried to change the default properties in the menu Evaluation->Parallel Kernel Configurations

The default was When needed, I have changed it to Manual, but Mathematica still tries to thread the computation over all the cores of the machine. Any idea?

If needed I am running version 12.3 for Linux

  • $\begingroup$ It would be nice if you provide an MWE so we could test our solutions. $\endgroup$ Feb 14 at 9:14

2 Answers 2


There are SystemOptions["ParallelOptions"]:

{"ParallelOptions" -> {"AbortPause" -> 2., "BusyWait" -> 0.01, "MathLinkTimeout" -> 15., 
   "MKLThreadNumber" -> 4, "ParallelThreadNumber" -> 4, "RecoveryMode" -> "Retry", 
   "RelaunchFailedKernels" -> True, 
   "VectorParallelLengthThresholds" -> {8192, 8192, 8192, 8192, 8192}, 
   "VectorVendorLengthThresholds" -> {128, 32, 32}}}

You can try changing the options:

SetSystemOptions["ParallelOptions" -> {"MKLThreadNumber" -> 1, "ParallelThreadNumber" -> 1}]

This works for the current Kernel session only.


Let say you want to use only 2 kernels:


To check how many kernels are in use currently, run


Controlling physical cores instead of kernels/threads is an OS-side problem. You can check how many physical cores are available in the machine via $ProcessorCount, which is based on what OS is telling Mathematica.


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.