-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Can't pickle local object #286
Comments
Hi, there seem to be several possibilities: I assume you do not specify a sampler in ABCSMC(), and thus use the default pyabc.sampler.MulticoreEvalParallelSampler? What OS do you use? If Windows, that is not tested unfortunately, and likely to fail as Windows does not support forking. If you need it, we can look into that. If Linux, this seems to be indeed strange, because afaik the forking employed in the multiprocessing module should not perform pickling at all. Only the results are pickled, but here it seems to try to pickle the simulate function. This can happen if your results somehow refer to the sampling function. To see what can cause the problem there (or whether the problem is due to some strange python setup after all), it would help if you can provide your model function. |
I’m using MacOS. The sampler is the one shown in the tutorial - I just copy-pasted the tutorial code from here https://pyabc.readthedocs.io/en/latest/examples/quickstart.html |
Ok. I cannot reproduce the error on my system (anaconda python 3.7.6, latest package versions), so it could be python (would it be feasible to try out an older version with python 3.7?) or mac. Unfortunately we have no mac available to us at the moment, which makes it hard to check (could try on travis). To make things run for you and if a performance loss of maybe 50% is not crucial at the moment, could you try out to specify the sampler |
Thanks for the quick reply! Using either |
Great it works now! Thanks for the information that it does not work for python 3.8. We will definitely need to address that at some point. I guess there may have been some changes to the multiprocessing module. |
@yoavram all CI tests are running on python 3.8, ubuntu 18.04 now, and the error cannot be reproduced. |
@yannikschaelte I am unfortunately getting this error on MacOS with Python 3.8.3. However, I don't get this error on Linux. |
Hi @vedantchandra it may be that in python3.8, To circumvent this, one could here wrap the arguments using |
Alternatively, |
@yannikschaelte Yes, I think that's the issue. Thankfully I don't need to parallelize on MacOS, I can run tests using the single-core sampler. Thank you for the help! |
I suggest that if it is not fixed (not a must, I guess, though some Max’s now have quite a lot of cores) then at least have the default sampler switch to a single core sampler instead of crashing. |
Hi @yoavram , sorry your comment has somehow gone unnoticed. Totally agreed. We will see whether there is a simple solution, otherwise fix the sampling to single-core on mac. |
Thanks! I’m using pyABC for a lecture in my course tomorrow: https://github.com/yoavram/SciComPy/blob/master/notebooks/ABC.ipynb |
Dear @yoavram , @vedantchandra the Multicore samplers should be usable now on MacOS in #320. They now have an additional |
fixed in #321 |
Thank you for this helpful thread! Unfortunately, I am a Windows user and now wonder whether a solution/work-around has been implemented in Windows as suggested above? |
When I run the tutorial, after running
abc.run(...)
I receive the following pickle error:AttributeError: Can't pickle local object 'ABCSMC._create_simulate_from_prior_function.<locals>.simulate_one'
Using Python 3.8 (Anaconda) with pyABC 0.10.1 (also tried 0.10.0 and 0.9.26 to the same result).
cloudpickle 1.3.0, pickleshare 0.7.5, and dill 0.3.1.1 are installed, too.
Running in Jupyter notebook, but I checked and it happens if I'm running the same code as a script.
Here is the full trace:
Please advise...
Thanks
The text was updated successfully, but these errors were encountered: