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

dm_control wrapper #165

Open
elle-miller opened this issue Jun 27, 2024 · 1 comment
Open

dm_control wrapper #165

elle-miller opened this issue Jun 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@elle-miller
Copy link

Description

Hi there,

I have been using skrl with OIGE, but when I try the "Getting Started" code for dm_control :

# import the environment wrapper and the deepmind suite
from skrl.envs.wrappers.torch import wrap_env
from dm_control import suite

# load the environment
env = suite.load(domain_name="cartpole", task_name="swingup")

# wrap the environment
env = wrap_env(env)  # or 'env = wrap_env(env, wrapper="dm")'

I get the following error:

[skrl:INFO] Environment class: dm_env._environment.Environment
INFO:skrl:Environment class: dm_env._environment.Environment
[skrl:INFO] Environment wrapper: DeepMind
INFO:skrl:Environment wrapper: DeepMind
Traceback (most recent call last):
  File "/home/elle/code/envs/sk_test/lib/python3.10/site-packages/skrl/envs/wrappers/torch/base.py", line 24, in __init__
    self._action_space = self._env.single_action_space
AttributeError: 'Environment' object has no attribute 'single_action_space'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elle/code/devel/skrl_play/test123.py", line 9, in <module>
    env = wrap_env(env)  # or 'env = wrap_env(env, wrapper="dm")'
  File "/home/elle/code/envs/sk_test/lib/python3.10/site-packages/skrl/envs/wrappers/torch/__init__.py", line 103, in wrap_env
    return DeepMindWrapper(env)
  File "/home/elle/code/envs/sk_test/lib/python3.10/site-packages/skrl/envs/wrappers/torch/deepmind_envs.py", line 19, in __init__
    super().__init__(env)
  File "/home/elle/code/envs/sk_test/lib/python3.10/site-packages/skrl/envs/wrappers/torch/base.py", line 27, in __init__
    self._action_space = self._env.action_space
AttributeError: 'Environment' object has no attribute 'action_space'. Did you mean: 'action_spec'?

This is with Python 3.10.14, dm_control==1.0.20 and skrl==1.1.0. It seems that in the inheritance of DeepMindWrapper from in the base Wrapper class, self._env.action_space is being called before self._spec_to_space can happen.

Also just as a heads up, when I try with skrl==1.2.0, I now get this:

Traceback (most recent call last):
  File "/home/elle/code/devel/skrl_play/test123.py", line 9, in <module>
    env = wrap_env(env)  # or 'env = wrap_env(env, wrapper="dm")'
  File "/home/elle/code/envs/sk_test/lib/python3.10/site-packages/skrl/envs/wrappers/torch/__init__.py", line 154, in wrap_env
    raise ValueError(f"Unknown wrapper type: {wrapper}")
ValueError: Unknown wrapper type: ['dm_env._environment.Environment']

Thank you!

What skrl version are you using?

1.1.0

What ML framework/library version are you using?

torch==2.3.1

Additional system information

Python 3.10.14

@elle-miller elle-miller added the bug Something isn't working label Jun 27, 2024
@Toni-SM
Copy link
Owner

Toni-SM commented Jun 30, 2024

Hi @elle-miller

Yes, in latest release (version 1.2.0) the automatic detection of the environment to be wrapped was updated and it didn't include DeepMind envs.

Regarding the AttributeError error when wrapping the DeepMind environment, the DeepMind wrapper is not maintained anymore and will be removed in next version in favor of Shimmy. See skrl's Shimmy examples for training using a DeepMind environment.

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

2 participants