Disaster model Theano op: RuntimeError: Chain 0 failed

Hello,
I am very new to PYMC3. I used the Disaster model Theano op code from the case study in PYMC3 examples. https://github.com/pymc-devs/pymc-examples/blob/main/examples/case_studies/disaster_model_theano_op.py

I have been experiencing the following error:

Traceback (most recent call last):

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/parallel_sampling.py”, line 136, in run
self._unpickle_step_method()

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/parallel_sampling.py”, line 119, in _unpickle_step_method
raise ValueError(unpickle_error)

ValueError: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.
The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “”, line 25, in
tr = pm.sample(1000, tune=500, start=start, step=[step1, step2], cores=2)

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/sampling.py”, line 557, in sample
trace = _mp_sample(**sample_args, **parallel_args)

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/sampling.py”, line 1476, in _mp_sample
for draw in sampler:

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/parallel_sampling.py”, line 480, in iter
draw = ProcessAdapter.recv_draw(self._active)

File “/Users/Nazareen/opt/anaconda3/lib/python3.8/site-packages/pymc3/parallel_sampling.py”, line 360, in recv_draw
raise error from old_error

RuntimeError: Chain 0 failed.

Could someone help me rectify the error.

Could you provide the version of pymc3, theano, and python as well as information about what platform (e.g., windows, etc.) you are using?

pymc3 - 3.10.0
theano - 1.0.11
python - 3.8.5
Platform - MacOS Big Sur

Very strange. It runs fine here. Could you try sampling on a single core?

tr = pm.sample(1000, tune=500, start=start, step=[step1, step2], cores=1)

It looks like the difficulty is stemming from the multithreading. I know that there was some difficulty in this area on windows machines, though I don’t recall seeing anything on Macs.

This works, but it does not work for 2 cores.

Ok, so it is the multi-threading. At least you now have the ability to run everything on a single core.

I might suggest poking around the related issues here and here. If there isn’t anything that seems related, you can submit a new issue highlighting the Mac-related problem you are experiencing. I know that there are others using pymc3 on Macs (e.g., pymc3 developer Chris Fonnesbeck), so I have to imagine that there is something more than just “pymc3 on a Mac can’t use more than one core”.

Thank you so much for your help. I’ll do that