Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
florath opened this issue May 22, 2019 · 8 comments

Comments

@florath
Copy link

florath commented May 22, 2019

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
@jeehyun100
Copy link

I got same error too. Help me.

@MathematicalModels
Copy link

Me too. Please help us.

@Lantc26
Copy link

Lantc26 commented Sep 24, 2019

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

johannespitz added a commit to johannespitz/baselines that referenced this issue Oct 8, 2019
 - Removed interfering calls to env.reset() in play mode.
   (Note that the worker in the subprocess is calling env.reset() already)

 - Fixed the printed reward when running multiple envs in play mode.
@johannespitz
Copy link
Contributor

#1015

pzhokhov pushed a commit that referenced this issue Oct 25, 2019
* Update the commands to install Tensorflow

The current 'tensorflow' package is for Tensorflow 2, which is not supported by the master branch of baselines.

* Update command to install Tensorflow 1.14

* Fix RuntimeError (#910)

 - Removed interfering calls to env.reset() in play mode.
   (Note that the worker in the subprocess is calling env.reset() already)

 - Fixed the printed reward when running multiple envs in play mode.
@seey0u
Copy link

seey0u commented Dec 20, 2019

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

@Lantc26
Copy link

Lantc26 commented Dec 20, 2019

I agree, the error occurs now for trpo_mpi and deepq

@yceny
Copy link

yceny commented Mar 9, 2021

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

@QingchenDang
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants