AttributeError: Can't pickle local object 'Op.make_py_thunk..rval' while running pymc3

I am new to PyMC3. While learning PyMC3, I recreated a program from a blog (which presumably ran for the author), and run into the following error: AttributeError: Can’t pickle local object ‘Op.make_py_thunk…rval’. I am completely stuck and any guidance will be appreciated. Relevant code follows:

log_dose = np.array([-.86, -.3, -.05, .73])
log_dose_shared = shared(log_dose)
n = 5 * np.ones(4, dtype = int)
n_shared = shared(n)
deaths = np.array([0, 1, 3, 5])

with Model() as bioassay_model:
# Logit model parameters
alpha = Normal(‘alpha’, 0, sd = 100)
beta = Normal(‘beta’, 0, sd = 100)
# Calculate probabilities of death
theta = invlogit(alpha + beta * log_dose_shared)
# Data likelihood
obs_death = Binomial(‘obs_death’, n = n_shared, p = theta, observed = deaths)

with bioassay_model:
# Obtain starting values via MAP
start = find_MAP(model = bioassay_model)
# Instantiate sampler
step = pm.Metropolis()
# Draw 2000 posterior samples
bioassay_trace = sample(50000, step = step, start = start)
logp = -13.034, ||grad|| = 0.00043389: 100%|██████████████████████████████████████████| 14/14 [00:00<00:00, 398.61it/s]
Multiprocess sampling (4 chains in 4 jobs)
CompoundStep

Metropolis: [beta]
Metropolis: [alpha]

_RemoteTraceback Traceback (most recent call last)
_RemoteTraceback:
Traceback (most recent call last):
File “C:\Users\bikim\AppData\Local\conda\conda\envs\pymc3p36\lib\site-packages\joblib\externals\loky\backend\queues.py”, line 151, in _feed
obj, reducers=reducers)
File “C:\Users\bikim\AppData\Local\conda\conda\envs\pymc3p36\lib\site-packages\joblib\externals\loky\backend\reduction.py”, line 145, in dumps
p.dump(obj)
AttributeError: Can’t pickle local object ‘Op.make_py_thunk…rval’

For completeness here is additional environment information:
I installed PyMC3 using conda
3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Running on PyMC3 version 3.4.1
Theano version: 1.0.2
Windows 10

I resolved this. Re-installing from the master branch appears to solve the problem : pip3 install -U git+https://github.com/pymc-devs/pymc3.git. I hope this helps others.

1 Like