exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

RV-multi tutorial is not working anymore (Jupyter notebook) #153

Closed LucaNap closed 3 years ago

LucaNap commented 3 years ago

I noticed that the RV multi tutorial is not working anymore, even in Jupyter notebook. The following error shows up after pmx.sample has been called:

AttributeError: Can't get attribute 'rv_model' on <module 'main' (built-in)>

I noticed that using the argument _picklebackend='dill' I can get the sample running but even so I am unable to get the results as if the sampling had been interrupted at some point. By the way I am referring to the tutorial because it's easier, but I first had this issue with some data of mine that I was trying to fit, but no matter how general or easy to fit the data is, I always get the same issue. Is there a way to circumvent this error? Thank you!

Setup

dfm commented 3 years ago

This tutorial runs just fine on Mac and Ubuntu (which are the two platforms that I develop on) so this is probably something to do with Windows and/or your specific setup. You could try changing the multiprocessing context parameter (perhaps fork vs forkserver) but I can't give too many tips since I don't often use Windows.

dfm commented 3 years ago

This is how I set it on Mac: https://github.com/exoplanet-dev/case-studies/blob/1e2b78e75b6617ad97a9e8a86cdf088d712c1f27/docs/tutorials/notebook_setup.py#L24

but you should also be able to use the mp_ctx="fork" parameter for sample directly.

LucaNap commented 3 years ago

Thank you! Unfortunately _mpctx='fork' or forkserver is not working either..

ValueError: cannot find context for 'fork'

https://github.com/lyft/l5kit/issues/129 apparently neither fork or forkserver are available on windows

dfm commented 3 years ago

Yes - that looks right: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

When you say this doesn't work "anymore" when did you have it working before? This behavior shouldn't have changed in the v0.4 stream. I'll try to give this a shot on windows at some point to see if I can figure out a workaround.

LucaNap commented 3 years ago

Sorry @dfm , I was able to get the tutorial working in Windows10 by using the argument _picklebackend='dill', contrary to what I have said in the opening post! Apparently the process did finish, I just made a mistake trying to call the results. But I guess this post will be useful to Windows user who have had the same issue..

By the way, trying to plot with corner does not work:

import corner
corner.corner(trace, var_names=["P", "K", "tp", "means", "sigmas"])

----> TypeError: cannot perform reduce with flexible type
dfm commented 3 years ago

Great news! Glad you got it working.

Again it does work: those tutorials are automatically generated by executing the code. So while there might be issues when you try to run it, the conclusion is not that it "doesn't work", but instead that there's an issue with your setup :D. In this case you'll probably need to update corner.