Hi all,
Hoping for some insight/help with solving the runtime error which occurs when trying to run the NUTS sampler (on very simple regression model example) with more than one chain (see below)? Running current pyMC3 v. 3.9.3.
Any insight would be much appreciated.
Cheers, Rod
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
BrokenPipeError: [Errno 32] Broken pipe
Hi Roderick,
I’m guessing you’re on Windows? In which case I think you have to set cores=1
in pm.sample
to disable multiprocessing
Hi Alex,
Magic, that solved the problem, thanks! Happily runs multiple chains in series now!
I am running on Macbook Pro MacOS Mojave 10.14.6 with a 3.1 GHz Intel Core i7 processor, which I believe has 2 cores? Is there a way to set things up so pymc3 can access both cores? Sorry if this is in FAQs.
Cheers, Rod
Try putting your code in a __main__
block, i.e.,
if __name__ == "__main__":
pm.sample(...)
It’s not totally clear what’s going on—some change to the default multiprocessing behavior in Python 3.8—but I ran into this a few weeks ago. See this Github issue for more, possibly.
2 Likes
Ah indeed, if you’re on MacOS you should be able to use multiprocessing. Depending on your how you’re using pm.sample
, @tushar_chandra’s solution will work
Sadly, it does not work for me, I keep getting the runtime error (broken pipe). I’m running PyMC3 on a MacBook running Big Sur 11.6.
Hey JP! Nice to see you here
Any reason you’re not using PyMC 4.0+ ? This is greatly improved
Hi Alex,
Good to hear from you! Good question, good answer. I will elaborate soon in a personal email to you!
Cheers, JP