California-Planet-Search / radvel

General Toolkit for Modeling Radial Velocity Data
http://radvel.readthedocs.io
MIT License
57 stars 52 forks source link

Runtime error in radvel.mcmc #327

Closed TheoMPhysics closed 3 years ago

TheoMPhysics commented 3 years ago

Hello! I am following the tutorial for K2-24 fitting on Windows, it seems like due to the multiprocessing limit on Windows I always get a Runtime error when I am running the following part:

df = radvel.mcmc(post,nwalkers=20,nrun=400,savename='rawchains.h5')

I am using: Windows 10, PyCharm 2020.2.1 Anaconda 3 Python 3.8

The detail of my error:

Traceback (most recent call last): File "", line 1, in File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 125, in _main prepare(preparation_data) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "C:\Users\Administrator\anaconda3\lib\runpy.py", line 265, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Users\Administrator\anaconda3\lib\runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Users\Administrator\anaconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Administrator\PycharmProjects\pythonProject1\wecandoit.py", line 88, in df = radvel.mcmc(post,nwalkers=20,nrun=400,savename='rawchains.h5') File "C:\Users\Administrator\anaconda3\lib\site-packages\radvel\mcmc.py", line 382, in mcmc pool = mp.Pool(statevars.ensembles) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\context.py", line 119, in Pool return Pool(processes, initializer, initargs, maxtasksperchild, File "C:\Users\Administrator\anaconda3\lib\multiprocessing\pool.py", line 212, in init self._repopulate_pool() File "C:\Users\Administrator\anaconda3\lib\multiprocessing\pool.py", line 303, in _repopulate_pool return self._repopulate_pool_static(self._ctx, self.Process, File "C:\Users\Administrator\anaconda3\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static w.start() File "C:\Users\Administrator\anaconda3\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\context.py", line 326, in _Popen return Popen(process_obj) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 45, in init prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "C:\Users\Administrator\anaconda3\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main raise RuntimeError(''' 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.

Could you please help me with it?

bjfultn commented 3 years ago

Thank you for the bug report. I must admit, our testing on Windows is pretty limited so this should help make the software more robust across all platforms (assuming we can track down the bug and squash it).

Do you see the same error if you set serial=True in the radvel.mcmc call?

TheoMPhysics commented 3 years ago

Thank you for the bug report. I must admit, our testing on Windows is pretty limited so this should help make the software more robust across all platforms (assuming we can track down the bug and squash it).

Do you see the same error if you set serial=True in the radvel.mcmc call?

Hello! Thanks for your suggestion! I tried the following this time:

df = radvel.mcmc(post,nwalkers=20,nrun=400,serial=True,savename='rawchains.h5')

and I got a following error, Or should I adjust something in the spawn.py?

radvel error mcmc
bjfultn commented 3 years ago

Sorry this issue has gone stale. Were you able to make any progress?

eloubrown commented 2 years ago

Thank you for the bug report. I must admit, our testing on Windows is pretty limited so this should help make the software more robust across all platforms (assuming we can track down the bug and squash it).

Do you see the same error if you set serial=True in the radvel.mcmc call?

This worked for me. Thanks!