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

[Bug Report] Incompatible with mujoco 3.0.0 #749

Closed
1 task done
bennevans opened this issue Oct 19, 2023 · 13 comments
Closed
1 task done

[Bug Report] Incompatible with mujoco 3.0.0 #749

bennevans opened this issue Oct 19, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@bennevans
Copy link

Describe the bug

When using mujoco 3.0.0 and gym version 0.29, human rendering crashes the code with the following error:

AttributeError: 'mujoco._structs.MjData' object has no attribute 'solver_iter'

It has to do with the change in names described here

Code example

import gymnasium as gym
env = gym.make("Hopper-v4", render_mode="human")

observation, info = env.reset(seed=42)
for _ in range(1000):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)
    env.render()
    if terminated or truncated:
        observation, info = env.reset()
env.close()

System info

Installed via pip version 0.29.1

Distro information
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy

Python 3.11

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo
@bennevans bennevans added the bug Something isn't working label Oct 19, 2023
@pseudo-rnd-thoughts
Copy link
Member

pseudo-rnd-thoughts commented Oct 20, 2023

Thanks for reporting, a PR has already been opened to fix this, #746

@Kallinteris-Andreas
Copy link
Collaborator

downgrade to 2.3.* in the meantime

@MohammedBadra
Copy link

Changing to solver_niter also works!

@pseudo-rnd-thoughts
Copy link
Member

This has been solved in #746

rickstaa added a commit to rickstaa/stable-gym that referenced this issue Oct 27, 2023
This commit ensures that the mujoco version that is installed is lower
than 3.0.0. This needed to be done since the latest gymnasium version is
not yet compatible with mujoco 3.0.0. See
Farama-Foundation/Gymnasium#749 for more
information.
@qlan3
Copy link

qlan3 commented Nov 11, 2023

I saw a similar error when using Swimmer-v4:

>>> import gymnasium as gym
>>> env = gym.make("Swimmer-v4")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/python3.9/site-packages/gymnasium/envs/registration.py", line 802, in make
    env = env_creator(**env_spec_kwargs)
  File "~/python3.9/site-packages/gymnasium/envs/mujoco/swimmer_v4.py", line 170, in __init__
    MujocoEnv.__init__(
  File "~/python3.9/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 360, in __init__
    super().__init__(
  File "~/python3.9/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 72, in __init__
    self.model, self.data = self._initialize_simulation()
  File "~/python3.9/site-packages/gymnasium/envs/mujoco/mujoco_env.py", line 380, in _initialize_simulation
    model = mujoco.MjModel.from_xml_path(self.fullpath)
ValueError: XML Error: Schema violation: unrecognized attribute: 'collision'

Package versions:

gymnasium                0.29.1
mujoco                   3.0.0
mujoco-py                2.1.2.14

@pseudo-rnd-thoughts
Copy link
Member

pseudo-rnd-thoughts commented Nov 13, 2023

@qlan3 This was addressed in #746

@Kallinteris-Andreas
Copy link
Collaborator

Kallinteris-Andreas commented Nov 13, 2023

@qlan3
you can pip install mujoco<3 or wait for gymansium==1.0.0 or use the git version of gymnasium

stephane-caron added a commit to stephane-caron/robotics-mva-2023 that referenced this issue Nov 15, 2023
@khoikhtn
Copy link

can anyone help me with changing solver_iter to solver_niter in vscode?

@Kallinteris-Andreas
Copy link
Collaborator

@khoikhtn #749 (comment)

@MatthewGerber
Copy link

@qlan3 you can pip install mujoco<3 or wait for gymansium==1.0.0 or use the git version of gymnasium

Thanks for clarifying the issue above! When do you anticipate releasing 1.0.0?

@pseudo-rnd-thoughts
Copy link
Member

@qlan3 you can pip install mujoco<3 or wait for gymansium==1.0.0 or use the git version of gymnasium

Thanks for clarifying the issue above! When do you anticipate releasing 1.0.0?

Sorry, we have been wishing to release for a couple of weeks but due to everyone being volunteers and holiday and conference it could be at the end of January is my guess. Though main is very close to the final release most likely

@MatthewGerber
Copy link

@qlan3 you can pip install mujoco<3 or wait for gymansium==1.0.0 or use the git version of gymnasium

Thanks for clarifying the issue above! When do you anticipate releasing 1.0.0?

Sorry, we have been wishing to release for a couple of weeks but due to everyone being volunteers and holiday and conference it could be at the end of January is my guess. Though main is very close to the final release most likely

No apology needed. I appreciate your help on this project and look forward to the new release. The workaround listed above is working for now.

MischaPanch added a commit to thu-ml/tianshou that referenced this issue Feb 6, 2024
Addresses part of #1015 

### Dependencies

- move jsonargparse and docstring-parser to dependencies to run hl
examples without dev
- create mujoco-py extra for legacy mujoco envs
- updated atari extra
    - removed atari-py and gym dependencies
    - added ALE-py, autorom, and shimmy
- created robotics extra for HER-DDPG

### Mac specific

- only install envpool when not on mac
- mujoco-py not working on macOS newer than Monterey
(openai/mujoco-py#777)
- D4RL also fails due to dependency on mujoco-py
(Farama-Foundation/D4RL#232)

### Other

- reduced training-num/test-num in example files to a number ≤ 20
(examples with 100 led to too many open files)
- rendering for Mujoco envs needs to be fixed on gymnasium side
(Farama-Foundation/Gymnasium#749)

---------

Co-authored-by: Maximilian Huettenrauch <m.huettenrauch@appliedai.de>
Co-authored-by: Michael Panchenko <35432522+MischaPanch@users.noreply.github.com>
@Nourine-Nadir
Copy link

Nourine-Nadir commented Jul 11, 2024

Describe the bug

When using mujoco 3.0.0 and gym version 0.29, human rendering crashes the code with the following error:

AttributeError: 'mujoco._structs.MjData' object has no attribute 'solver_iter'

It has to do with the change in names described here

Code example

import gymnasium as gym
env = gym.make("Hopper-v4", render_mode="human")

observation, info = env.reset(seed=42)
for _ in range(1000):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)
    env.render()
    if terminated or truncated:
        observation, info = env.reset()
env.close()

System info

Installed via pip version 0.29.1

Distro information Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

Python 3.11

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo

I tried this and it works,

  1. uninstall both gymnasium and mujoco if already installed,

  2. pip install mujoco==2.3.5
    then,

  3. pip install gymnasium

This will automatically take care of compatibility. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants