freeze_support runtime error with provided example
sofroniewn opened this issue ยท 4 comments
Hello, I'm trying out JANUS and if I just run the example inside the tests as provided I get
File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/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.
This can be fixed by wrapping the creation and running of the JANUS agent and inside
if __name__ == '__main__':
torch.multiprocessing.freeze_support()
see for a similar fix pytorch/pytorch#5858 (comment)
I'm happy to submit a PR to fix if you like - it will be very simple
Thanks for the comments @sofroniewn :)
@gkwt: will be looking into all of these!
Thank you for reporting this issue. I am unable to reproduce this error. Perhaps this an issue specific to the conda version of pytorch?
Either way, I can move the code in example.py
into the recommended
if __name__ == '_main__':
torch.multiprocessing.freeze_support()
The code still runs fine for me.
I am unable to reproduce this error. Perhaps this an issue specific to the conda version of pytorch?
quite possible - i'm on py3.9, macos x, torch 1.10.2 - in case anyone wants to look in further