openai / baselines

OpenAI Baselines: high-quality implementations of reinforcement learning algorithms
MIT License
15.75k stars 4.87k forks source link

NotImplementedError when executing Pong example #272

Closed shakenes closed 6 years ago

shakenes commented 6 years ago

Hey guys, first of all thanks a lot for this project. It might become handy during my studies :)

I ran into an error while executing the example. I downloaded the pretrained model, but python3 -m baselines.deepq.experiments.atari.enjoy --model-dir /tmp/models/model-atari-duel-pong-1 --env Pong --dueling raised the following error:

[2018-01-31 12:24:50,221] Making new env: PongNoFrameskip-v4
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/username/keras-tf-p3/baselines/baselines/deepq/experiments/atari/enjoy.py", line 70, in <module>
    play(env, act, args.stochastic, args.video)
  File "/home/username/keras-tf-p3/baselines/baselines/deepq/experiments/atari/enjoy.py", line 43, in play
    obs = env.reset()
  File "/home/username/keras-tf-p3/baselines/baselines/common/atari_wrappers.py", line 167, in reset
    ob = self.env.reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 104, in reset
    return self._reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 283, in _reset
    return self.env.reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 104, in reset
    return self._reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 310, in _reset
    observation = self.env.reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 104, in reset
    return self._reset()
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 311, in _reset
    return self._observation(observation)
  File "/home/username/keras-tf-p3/lib/python3.4/site-packages/gym/core.py", line 321, in _observation
    raise NotImplementedError
NotImplementedError

The cartpole example however works fine (python -m baselines.deepq.experiments.train_cartpole)

I found this issue in gym (https://github.com/openai/gym/issues/775) with the same error message, but mine seems to occur in reset() and not in render(). Downgrading to pyglet version 1.2.4 as suggested did not change anything.

Does someone know a solution to this?

shakenes commented 6 years ago

I found the solution: The NotImplementedError was due to an old gym version. Updating to latest gym version leads to cannot import name spaces error which can be solved by https://github.com/openai/gym/pull/858

fi000 commented 6 years ago

simontudo : how you update gym? Which version of gym you are using?

shakenes commented 6 years ago

Depends on how you installed it. If you just installed it via pip then execute pip install gym --upgrade If you cloned the git repository first, you need to cd to the repo, execute git pull and then pip install -e .

I installed gym from the github repo, so it's the latest version.

fi000 commented 6 years ago

Simontudo Thanks I have installed it from github repo Also I have updated it by command However, my problem remains the same. I saw the same error for another code I am using gym!

Your problem is solved by just doing update nothing else?

shakenes commented 6 years ago

So you have the latest versions of baselines and gym and still getting the NotImplementedError?

When I updated gym, I got cannot import name spaces and solved it with https://github.com/openai/gym/pull/858

fi000 commented 6 years ago

Yes, I have this problem(NotImplementedError)when I donwloaded from https://github.com/openai/gym The version of my python is 3.5.6 I saw today the following comments in github for gym it has written: (Did you make these changes? If so, could you explain what we should do clearly? Sorry for misunderstanding) What's new 2018-01-25: Made some aesthetic improvements and removed unmaintained parts of gym. This may seem like a downgrade in functionality, but it is actually a long-needed cleanup in preparation for some great new things that will be released in the next month.

Now your Env and Wrapper subclasses should define step, reset, render, close, seed rather than underscored method names. Removed the board_game, debugging, safety, parameter_tuning environments since they're not being maintained by us at OpenAI. We encourage authors and users to create new repositories for these environments. Changed MultiDiscrete action space to range from [0, ..., n-1] rather than [a, ..., b-1]. No more render(close=True), use env-specific methods to close the rendering. Removed scoreboard directory, since site doesn't exist anymore. Moved gym/monitoring to gym/wrappers/monitoring Add dtype to Space. Not using python's built-in module anymore, using gym.logger 2018-01-24: All continuous control environments now use mujoco_py >= 1.50. Versions have been updated accordingly to -v2, e.g. HalfCheetah-v2. Performance should be similar (see https://github.com/openai/gym/pull/834) but there are likely some differences due to changes in MuJoCo.

nevenaBlagoeva commented 5 years ago

Hello, I am facing the same issue as described above, do you know if there has been any solution? Upgrading gym did nothing for me!

MouseHu commented 4 years ago

Hello, I am facing the same issue as described above, do you know if there has been any solution? Upgrading gym did nothing for me!

Have you solved your problem? I fix the issue by downgrade the version of gym.

fahad-30 commented 4 years ago

I have the same problem as well

NoobHua commented 3 years ago

It may be a version-conflict problem. Upgrading the gym or Downgrading can solve it.

hudsontek commented 3 years ago

It may be a version-conflict problem. Upgrading the gym or Downgrading can solve it.

In my case, downgrading from 0.18 to 0.10 solved the problem.

Joshwlks commented 3 years ago

I am having this issue too. I can't have a version of gym outside of 0.15.4 and 0.16.0 because of baselines