baselines icon indicating copy to clipboard operation
baselines copied to clipboard

Example play from main Readme stops after a short time with: RuntimeError: Tried to step environment that needs reset

Open florath opened this issue 6 years ago • 8 comments

I tried to run the example as given on the main Readme:

python -m baselines.run --alg=ppo2 --env=PongNoFrameskip-v4 --num_timesteps=0 --load_path=./models/pong_20M_ppo2 --play

it stops after a short time with:

Process SpawnProcess-3:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/subproc_vec_env.py", line 19, in worker
    ob = env.reset()
  File "/home/florath/devel/ML01/vml/lib/python3.7/site-packages/gym/core.py", line 287, in reset
    return self.env.reset(**kwargs)
  File "/home/florath/devel/ML01/vml/lib/python3.7/site-packages/gym/core.py", line 277, in reset
    observation = self.env.reset(**kwargs)
  File "/home/florath/devel/ML01/baselines/baselines/common/atari_wrappers.py", line 50, in reset
    obs, _, done, _ = self.env.step(1)
  File "/home/florath/devel/ML01/baselines/baselines/common/atari_wrappers.py", line 71, in step
    obs, reward, done, info = self.env.step(action)
  File "/home/florath/devel/ML01/baselines/baselines/bench/monitor.py", line 55, in step
    raise RuntimeError("Tried to step environment that needs reset")
RuntimeError: Tried to step environment that needs reset
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/florath/devel/ML01/baselines/baselines/run.py", line 244, in <module>
    main(sys.argv)
  File "/home/florath/devel/ML01/baselines/baselines/run.py", line 237, in main
    obs = env.reset()
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/vec_frame_stack.py", line 27, in reset
    obs = self.venv.reset()
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/subproc_vec_env.py", line 83, in reset
    return _flatten_obs([remote.recv() for remote in self.remotes])
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/subproc_vec_env.py", line 83, in <listcomp>
    return _flatten_obs([remote.recv() for remote in self.remotes])
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 407, in _recv_bytes
    buf = self._recv(4)
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 383, in _recv
    raise EOFError
EOFError
Exception ignored in: <function SubprocVecEnv.__del__ at 0x7f818c1ce620>
Traceback (most recent call last):
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/subproc_vec_env.py", line 107, in __del__
    self.close()
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/vec_env.py", line 98, in close
    self.close_extras()
  File "/home/florath/devel/ML01/baselines/baselines/common/vec_env/subproc_vec_env.py", line 91, in close_extras
    remote.send(('close', None))
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 404, in _send_bytes
    self._send(header + buf)
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe

florath avatar May 22 '19 11:05 florath

I got same error too. Help me.

jeehyun100 avatar Jul 05 '19 08:07 jeehyun100

Me too. Please help us.

MathematicalModels avatar Aug 30 '19 08:08 MathematicalModels

I get the same error for a2c, acktr, ppo2 and acer. However, the error is not thrown for deepq and trpo.

Lantc26 avatar Sep 24 '19 13:09 Lantc26

#1015

johannespitz avatar Oct 08 '19 16:10 johannespitz

I find that if you delete the 'obs = env.reset()' in the 'run.py', the error is thrown for deepq.

seey0u avatar Dec 20 '19 14:12 seey0u

I agree, the error occurs now for trpo_mpi and deepq

Lantc26 avatar Dec 20 '19 23:12 Lantc26

Is this issue fixed? I got the same error today. but it worked yesterday....

yceny avatar Mar 09 '21 19:03 yceny

Still getting the same error. Anyone know how to fix it?

QingchenDang avatar Apr 17 '21 22:04 QingchenDang