Farama-Foundation / D4RL

A collection of reference environments for offline reinforcement learning
Apache License 2.0
1.35k stars 285 forks source link

[Bug Report] gym 0.24.1 get error to run adroit environment #192

Closed egg-west closed 1 year ago

egg-west commented 1 year ago

With the gym version 0.24.1, I got an error to run environment "pen-human-v0", which is from the calling env.reset()

Traceback (most recent call last):
  File "train_offline_td3bc.py", line 89, in <module>
    app.run(main)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "train_offline_td3bc.py", line 81, in main
    eval_info = evaluate_normalized_state(agent, env, FLAGS.eval_episodes, state_mean.squeeze(0), state_std.squeeze(0))
  File "/mnt/c/Users/zarathustra/Documents/jaxOfflineRL/jaxOfflineRL/evaluation.py", line 25, in evaluate_normalized_state
    observation, done = env.reset(), False
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/wrappers/record_episode_statistics.py", line 97, in reset
    observations = super().reset(**kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/core.py", line 339, in reset
    return self.env.reset(**kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/core.py", line 339, in reset
    return self.env.reset(**kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/core.py", line 339, in reset
    return self.env.reset(**kwargs)
  [Previous line repeated 1 more time]
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/core.py", line 401, in reset
    return self.observation(self.env.reset(**kwargs))
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/wrappers/time_limit.py", line 66, in reset
    return self.env.reset(**kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/wrappers/order_enforcing.py", line 42, in reset
    return self.env.reset(**kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/wrappers/env_checker.py", line 47, in reset
    return passive_env_reset_check(self.env, **kwargs)
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/utils/passive_env_checker.py", line 247, in passive_env_reset_check
    _check_obs(obs, env.observation_space, "reset")
  File "/home/linjx/anaconda3/envs/jaxEnv/lib/python3.8/site-packages/gym/utils/passive_env_checker.py", line 113, in _check_obs
    assert observation_space.contains(
AssertionError: The observation returned by the `reset()` method is not contained with the observation space (Box(-inf, inf, (45,), float32))

I change the gym to a version of 0.23.0 and it fixed this issue.

egg-west commented 1 year ago

I printed the sate received by the assert

[ 0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00 -2.00000000e-01  2.50000000e-01  0.00000000e+00
  0.00000000e+00  0.00000000e+00  0.00000000e+00  0.00000000e+00
  0.00000000e+00  9.99999683e-01  0.00000000e+00  7.96326711e-04
 -7.87498925e-01 -2.78412503e-01  5.49847180e-01  0.00000000e+00
  0.00000000e+00  0.00000000e+00  1.78749861e+00  2.78412503e-01
 -5.49050853e-01]
pseudo-rnd-thoughts commented 1 year ago

Gym v0.24 has known issues and reports this on import gym. I would recommend using v0.23 or v0.25

egg-west commented 1 year ago

@pseudo-rnd-thoughts Good point! Maybe we can change the requirements for gym to the correct versions.

pseudo-rnd-thoughts commented 1 year ago

Done, I have updated setup.py to <0.24