Parallel analysis

I am using PyMC3 for a long time. But I have never been successful to run a model with njobs more than 1. I was thinking there is a problem maybe with my computing system. But then I installed pymc in several other computers and I was not successful. I convinced I probably miss something. It is not only as easy to changing njobs in “sample” command.
Please advice me in this regard. What is wrong? maybe because I use windows?~Thanks!

What kind of error you usually see? Sometimes it is memory problem, is it work with a small toy model?

It never worked for any of my models in several different systems (all with windows 10). I am going to make a simple model now, and I will run it and I will update here.

1 Like

So this is the simple code:

#%%
import numpy as np;
import matplotlib.pyplot as plt;
import pymc3 as pm;
#%%
observed_data=np.random.normal(3,1,20)
basic_model = pm.Model()
with basic_model:
    # Priors for unknown model parameters
    a = pm.Normal('a', 5, 5)
    s=pm.HalfNormal('sigma_lik',sd=5)
    Y_obs = pm.Normal('Y_obs', mu=a, sd=s, observed=observed_data)
    trace=pm.sample( 10000, tune= 2000, njobs=1)
pm.traceplot(trace)

For njobs=1 it is what I get:
C:\ProgramData\Anaconda3\lib\site-packages\h5py_init_.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from .conv import register_converters as register_converters
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Sequential sampling (2 chains in 1 job)
NUTS: [sigma_lik_log
, a]
100%|██████████| 12000/12000 [00:18<00:00, 660.53it/s]
100%|██████████| 12000/12000 [00:10<00:00, 1112.94it/s]
The model with njobs=1 was fast and done in few seconds. With njobs=2 it is still running and chain apparently does not even start. I provide you the screenshot.

Hmm, I recalled that someone also reported a similar error under Spyder, did you try to run it in a notebook or from a Terminal?

I did not. I will and keep you updated. I am not in front of the computer now.

Thanks!

I ran the code in a terminal and I got error, I should say that I did not do any ctrl+c
Here are the results:

hmm quite likely it is a Windows problem… What kind of C++ library you are using? How do you install pymc3? Is it with anaconda?

Yes, I used anaconda to install everything possible including pymc3. About C++ I am not a user for C++, but I guess I should use following command on command prompt to see the version and it is what I got: