Hi, my model runs succesfully ( a very simple ode model ) and my posterior is reasonable.
However, when I specify more cores in the sample method, I always get the error:
Could not pickle model, sampling singlethreaded.
Sequential sampling (4 chains in 1 job)
The sampling still completes, and for the case of this simple problem it takes 37 seconds for 1000 tunes and 1000 draws over 4 chains.
However, I would like to know if there is anything I can do to make sure multiple cores are used instead of sequential sampling. I could see from other forms that windows might be the problem but still would like to confirm.
I have tried using the if __name__ == '__main__':
method, but it has no impact on my output.
The sampling code for those who want to know:
def run_model_slice(vars_list, model, tune, draws, chains=4, cores=4):
with model:
trace = pm.sample(step=[pm.Slice(vars_list)], tune=tune, draws=draws, chains=chains, cores=cores)
return trace
trace_slice = run_model_slice(vars_list=vars_list, model=model, tune=tune, draws=draws, chains=4, cores=4)
Information on my setup:
Windows 11 version 23H2
VSCode with Jupyter Notebook
Anaconda environment with PyMC version 5.13.1