ValueError: cannot find context for 'fork'
jia-fiee opened this issue · comments
Dear author:
Thanks for your sharing! I am really interested in your work! I'm a undergraduate student and new to reinforcement learning.
When I type "python main.py --no-cuda ", I get that error quickly.
Traceback (most recent call last):
File "main.py", line 61, in
main(args)
File "main.py", line 43, in main
envs = make_vec_envs(args, './logs/runinfo', True)
File "G:\graduate design\code\Online-3D-BPP-PCT\envs.py", line 112, in make_vec_envs
envs = ShmemVecEnv(envs, spaces, context='fork')
File "G:\graduate design\code\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 30, in init
ctx = mp.get_context(context)
File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 238, in get_context
return super().get_context(method)
File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 192, in get_context
raise ValueError('cannot find context for %r' % method) from None
ValueError: cannot find context for 'fork'
Thanks in advance.
Regards
Dear author: Thanks for your sharing! I am really interested in your work! I'm a undergraduate student and new to reinforcement learning. When I type "python main.py --no-cuda ", I get that error quickly.
Traceback (most recent call last): File "main.py", line 61, in main(args) File "main.py", line 43, in main envs = make_vec_envs(args, './logs/runinfo', True) File "G:\graduate design\code\Online-3D-BPP-PCT\envs.py", line 112, in make_vec_envs envs = ShmemVecEnv(envs, spaces, context='fork') File "G:\graduate design\code\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 30, in init ctx = mp.get_context(context) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 238, in get_context return super().get_context(method) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 192, in get_context raise ValueError('cannot find context for %r' % method) from None ValueError: cannot find context for 'fork'
Thanks in advance.
Regards
Hello,
Thank you for your attention, I have updated the relevant code, now the command ‘python main.py --no-cuda ’ works on my computer. If the new code still doesn't work for you, I suggest you adjust torch and python to the recommended version.
Best wishes!
Thank you for your reply,I adjust torch and python to the recommended version.
However,when I type "python main.py ", I still get that error quickly.
My torcn version is 1.10.1+cu111 and my python version is 3.7.7.
Traceback (most recent call last):
File "main.py", line 61, in
main(args)
File "main.py", line 43, in main
envs = make_vec_envs(args, './logs/runinfo', True)
File "G:\graduate design\code\Online-3D-BPP-PCT\envs.py", line 112, in make_vec_envs
envs = ShmemVecEnv(envs, spaces, context='fork')
File "G:\graduate design\code\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 30, in init
ctx = mp.get_context(context)
File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 238, in get_context
return super().get_context(method)
File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 192, in get_context
raise ValueError('cannot find context for %r' % method) from None
ValueError: cannot find context for 'fork'
My conda list :
absl-py 1.0.0 pypi_0 pypi
blas 1.0 mkl
ca-certificates 2022.2.1 haa95532_0
cachetools 5.0.0 pypi_0 pypi
certifi 2021.10.8 py37haa95532_2
charset-normalizer 2.0.12 pypi_0 pypi
cloudpickle 1.2.2 pypi_0 pypi
dataclasses 0.6 pypi_0 pypi
future 0.18.2 pypi_0 pypi
google-auth 2.6.0 pypi_0 pypi
google-auth-oauthlib 0.4.6 pypi_0 pypi
grpcio 1.44.0 pypi_0 pypi
gym 0.15.7 pypi_0 pypi
gym-notices 0.0.4 pypi_0 pypi
idna 3.3 pypi_0 pypi
importlib-metadata 4.11.1 pypi_0 pypi
intel-openmp 2021.4.0 haa95532_3556
markdown 3.3.6 pypi_0 pypi
mkl 2021.4.0 haa95532_640
mkl-service 2.4.0 py37h2bbff1b_0
mkl_fft 1.3.1 py37h277e83a_0
mkl_random 1.2.2 py37hf11a4ad_0
numpy 1.21.5 py37ha4e8547_0
numpy-base 1.21.5 py37hc2deb75_0
oauthlib 3.2.0 pypi_0 pypi
opencv-python 4.2.0.34 pypi_0 pypi
openssl 1.1.1m h2bbff1b_0
pillow 9.0.1 pypi_0 pypi
pip 21.2.4 py37haa95532_0
protobuf 3.19.4 pypi_0 pypi
pyasn1 0.4.8 pypi_0 pypi
pyasn1-modules 0.2.8 pypi_0 pypi
pygame 2.1.2 pypi_0 pypi
pyglet 1.5.0 pypi_0 pypi
python 3.7.7 h81c818b_4
requests 2.27.1 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rsa 4.8 pypi_0 pypi
scipy 1.7.3 pypi_0 pypi
setuptools 58.0.4 py37haa95532_0
six 1.16.0 pyhd3eb1b0_1
sqlite 3.37.2 h2bbff1b_0
tensorboard 2.8.0 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.1 pypi_0 pypi
tensorboardx 2.5 pypi_0 pypi
torch 1.10.1+cu111 pypi_0 pypi
typing-extensions 4.1.1 pypi_0 pypi
urllib3 1.26.8 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
werkzeug 2.0.3 pypi_0 pypi
wheel 0.37.1 pyhd3eb1b0_0
wincertstore 0.2 py37haa95532_2
zipp 3.7.0 pypi_0 pypi
Thanks in advance.
Regards
Thank you for your reply,I adjust torch and python to the recommended version.
However,when I type "python main.py ", I still get that error quickly.
My torcn version is 1.10.1+cu111 and my python version is 3.7.7.
Traceback (most recent call last): File "main.py", line 61, in main(args) File "main.py", line 43, in main envs = make_vec_envs(args, './logs/runinfo', True) File "G:\graduate design\code\Online-3D-BPP-PCT\envs.py", line 112, in make_vec_envs envs = ShmemVecEnv(envs, spaces, context='fork') File "G:\graduate design\code\Online-3D-BPP-PCT\wrapper\shmem_vec_env.py", line 30, in init ctx = mp.get_context(context) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 238, in get_context return super().get_context(method) File "E:\anaconda\envs\Online3D\lib\multiprocessing\context.py", line 192, in get_context raise ValueError('cannot find context for %r' % method) from None ValueError: cannot find context for 'fork'
My conda list : absl-py 1.0.0 pypi_0 pypi blas 1.0 mkl ca-certificates 2022.2.1 haa95532_0 cachetools 5.0.0 pypi_0 pypi certifi 2021.10.8 py37haa95532_2 charset-normalizer 2.0.12 pypi_0 pypi cloudpickle 1.2.2 pypi_0 pypi dataclasses 0.6 pypi_0 pypi future 0.18.2 pypi_0 pypi google-auth 2.6.0 pypi_0 pypi google-auth-oauthlib 0.4.6 pypi_0 pypi grpcio 1.44.0 pypi_0 pypi gym 0.15.7 pypi_0 pypi gym-notices 0.0.4 pypi_0 pypi idna 3.3 pypi_0 pypi importlib-metadata 4.11.1 pypi_0 pypi intel-openmp 2021.4.0 haa95532_3556 markdown 3.3.6 pypi_0 pypi mkl 2021.4.0 haa95532_640 mkl-service 2.4.0 py37h2bbff1b_0 mkl_fft 1.3.1 py37h277e83a_0 mkl_random 1.2.2 py37hf11a4ad_0 numpy 1.21.5 py37ha4e8547_0 numpy-base 1.21.5 py37hc2deb75_0 oauthlib 3.2.0 pypi_0 pypi opencv-python 4.2.0.34 pypi_0 pypi openssl 1.1.1m h2bbff1b_0 pillow 9.0.1 pypi_0 pypi pip 21.2.4 py37haa95532_0 protobuf 3.19.4 pypi_0 pypi pyasn1 0.4.8 pypi_0 pypi pyasn1-modules 0.2.8 pypi_0 pypi pygame 2.1.2 pypi_0 pypi pyglet 1.5.0 pypi_0 pypi python 3.7.7 h81c818b_4 requests 2.27.1 pypi_0 pypi requests-oauthlib 1.3.1 pypi_0 pypi rsa 4.8 pypi_0 pypi scipy 1.7.3 pypi_0 pypi setuptools 58.0.4 py37haa95532_0 six 1.16.0 pyhd3eb1b0_1 sqlite 3.37.2 h2bbff1b_0 tensorboard 2.8.0 pypi_0 pypi tensorboard-data-server 0.6.1 pypi_0 pypi tensorboard-plugin-wit 1.8.1 pypi_0 pypi tensorboardx 2.5 pypi_0 pypi torch 1.10.1+cu111 pypi_0 pypi typing-extensions 4.1.1 pypi_0 pypi urllib3 1.26.8 pypi_0 pypi vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 werkzeug 2.0.3 pypi_0 pypi wheel 0.37.1 pyhd3eb1b0_0 wincertstore 0.2 py37haa95532_2 zipp 3.7.0 pypi_0 pypi
Thanks in advance.
Regards
I just added a new code update, maybe this version will work.
Thank you for your reply, I tried the latest version updated 13 minutes ago.
Unfortunately this error still exists, I don't know what is the reason.
Thank you for your reply, I tried the latest version updated 13 minutes ago.
Unfortunately this error still exists, I don't know what is the reason.
Is your operating system Windows?
Thank you for your reply, I tried the latest version updated 13 minutes ago.
Unfortunately this error still exists, I don't know what is the reason.Is your operating system Windows?
Yes
Thank you for your reply, I tried the latest version updated 13 minutes ago.
Unfortunately this error still exists, I don't know what is the reason.Is your operating system Windows?
Yes
I haven't run this code on Windows, since Ubuntu (16.04 for me) is more convenient for general academic research. This problem may be caused by multiprocessing package on Windows, ( the similar question see https://stackoverflow.com/questions/46021456/configure-multiprocessing-in-python-to-use-forkserver ). Unfortunately, you may need to solve this problem independently on your own operating system, wish you good luck.
Thank you very much for your reply.I finally successfully ran the code of this project on Ubuntu 18.04.Your suggestion for the problem in Windows system is very correct.
Thank you again for your reply, thanks a lot!