pfnet / pfrl

PFRL: a PyTorch-based deep reinforcement learning library
MIT License
1.2k stars 157 forks source link

Multiprocessing #180

Open kt71079 opened 1 year ago

kt71079 commented 1 year ago

I encountered following error:

hogehoge\pfrl-master\examples\atari>python train_ppo_ale.py

Output files are saved in results\20230128T163113.362308
Traceback (most recent call last):
  File "train_ppo_ale.py", line 334, in <module>
    main()
  File "train_ppo_ale.py", line 208, in main
    sample_env = make_batch_env(test=False)
  File "train_ppo_ale.py", line 201, in make_batch_env
    for idx, env in enumerate(range(args.num_envs))
  File "<my_env>\pfrl\lib\site-packages\pfrl\envs\multiprocess_vector_env.py", line 64, in __init__
    p.start()
  File "<my_env>\pfrl\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "<my_env>\pfrl\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "<my_env>\pfrl\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "<my_env>\pfrl\lib\multiprocessing\popen_spawn_win32.py", line 89, in __init__
    reduction.dump(process_obj, to_child)
  File "<my_env>\pfrl\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'main.<locals>.make_env'
Exception ignored in: <function MultiprocessVectorEnv.__del__ at 0x000001142E2B0F78>
Traceback (most recent call last):
  File "<my_env>\pfrl\lib\site-packages\pfrl\envs\multiprocess_vector_env.py", line 71, in __del__
    if not self.closed:
AttributeError: 'MultiprocessVectorEnv' object has no attribute 'closed'

hogehoge\pfrl-master\examples\atari>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<my_env>\pfrl\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "<my_env>\pfrl\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

This error seems to happen in multiprocessing module.

How can I solve this problem?

prabhatnagarajan commented 7 months ago

Hi sorry for this extremely late reply. The fix for me was to move make_env outside of main.