werner-duvaud / muzero-general

MuZero
https://github.com/werner-duvaud/muzero-general/wiki/MuZero-Documentation
MIT License
2.46k stars 606 forks source link

Render model #197

Open theeduardomora opened 2 years ago

theeduardomora commented 2 years ago

Search before asking

🐛 Describe the bug

I was trying to render my model and see how it performs on the Atari game breakout, but I encounter this error and don't know how to resolve this:

TypeError: render() missing 1 required positional argument: 'mode'

Add an example

Stack Trace:

0. Train
1. Load pretrained model
2. Diagnose model
3. Render some self play games
4. Play against MuZero
5. Test the game manually
6. Hyperparameter search
7. Exit
Enter a number to choose an action: 3
Testing 1/1
(SelfPlay pid=16394) /usr/local/lib/python3.7/dist-packages/ale_py/roms/__init__.py:94: DeprecationWarning: Automatic importing of atari-py roms won't be supported in future releases of ale-py. Please migrate over to using `ale-import-roms` OR an ALE-supported ROM package. To make this warning disappear you can run `ale-import-roms --import-from-pkg atari_py.atari_roms`.For more information see: https://github.com/mgbellemare/Arcade-Learning-Environment#rom-management
(SelfPlay pid=16394)   _RESOLVED_ROMS = _resolve_roms()
(SelfPlay pid=16394) A.L.E: Arcade Learning Environment (version 0.7.4+069f8bd)
(SelfPlay pid=16394) [Powered by Stella]
(SelfPlay pid=16394) /usr/local/lib/python3.7/dist-packages/gym/utils/seeding.py:160: DeprecationWarning: WARN: Function `hash_seed(seed, max_bytes)` is marked as deprecated and will be removed in the future. 
(SelfPlay pid=16394)   "Function `hash_seed(seed, max_bytes)` is marked as deprecated and will be removed in the future. "
(SelfPlay pid=16394) /usr/local/lib/python3.7/dist-packages/gym/utils/seeding.py:204: DeprecationWarning: WARN: Function `_bigint_from_bytes(bytes)` is marked as deprecated and will be removed in the future. 
(SelfPlay pid=16394)   "Function `_bigint_from_bytes(bytes)` is marked as deprecated and will be removed in the future. "
(SelfPlay pid=16394) /usr/local/lib/python3.7/dist-packages/gym/utils/passive_env_checker.py:98: UserWarning: WARN: We recommend you to use a symmetric and normalized Box action space (range=[-1, 1]) https://stable-baselines3.readthedocs.io/en/master/guide/rl_tips.html
(SelfPlay pid=16394)   "We recommend you to use a symmetric and normalized Box action space (range=[-1, 1]) "
(SelfPlay pid=16394) /usr/local/lib/python3.7/dist-packages/gym/utils/passive_env_checker.py:234: UserWarning: WARN: Future gym versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information.
(SelfPlay pid=16394)   "Future gym versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information."
Traceback (most recent call last):
  File "muzero.py", line 680, in <module>
    muzero.test(render=True, opponent="self", muzero_player=None)
  File "muzero.py", line 405, in test
    muzero_player,
  File "/usr/local/lib/python3.7/dist-packages/ray/_private/client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/ray/worker.py", line 1831, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(TypeError): ray::SelfPlay.play_game() (pid=16394, ip=172.28.0.2, repr=<self_play.SelfPlay object at 0x7fbe5d7acf10>)
  File "/content/drive/MyDrive/muzero-general/self_play.py", line 126, in play_game
    self.game.render()
  File "/content/drive/MyDrive/muzero-general/games/breakout.py", line 198, in render
    self.env.render()
  File "/usr/local/lib/python3.7/dist-packages/gym/core.py", line 343, in render
    return self.env.render(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/gym/wrappers/order_enforcing.py", line 51, in render
    return self.env.render(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/gym/wrappers/env_checker.py", line 55, in render
    return passive_env_render_check(self.env, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/gym/utils/passive_env_checker.py", line 310, in passive_env_render_check
    return env.render(**kwargs)
TypeError: render() missing 1 required positional argument: 'mode'

Environment

No response

Minimal Reproducible Example

No response

Additional

No response

KexianShen commented 2 years ago

downgrade gym to 0.21.0 may solve your problem