NUTS sampler uses all cores as kernel threads


When I run a NUTS smapler, it uses all cores as kernel threads even though I set cores=1.
I tried

import os
os.environ[“OMP_NUM_THREADS”] = “1”
os.system(‘export MKL_NUM_THREADS=1’)
os.system(‘export NUMEXPR_NUM_THREADS=1’)
os.system(‘export OMP_NUM_THREADS=1’)
But didn’t help.

It works fine for other models. For a problematic one, I’m using tensor.slinalg.solve(). This may be causing a problem.
If you know how to fix this, please let me know.


We’ll need to know which version of PyMC3 you are using.
Also please try to provide a minimum reproducible example.

The decision logic behind pm.sample is a bit convoluted: PyMC3 Internals (for devs) · pymc-devs/pymc3 Wiki · GitHub