pytorch / rl

A modular, primitive-first, python-first PyTorch library for Reinforcement Learning.
https://pytorch.org/rl
MIT License
2.19k stars 289 forks source link

[BUG] torchrl doesn't support minigrid gymnasium environments #1467

Closed kbkartik closed 2 days ago

kbkartik commented 1 year ago

I am trying to parallelize FourRooms minigrid environment using torchrl. Following is my code:

class MinigridGymWrapper(GymWrapper):
    """FARAMA Minigrid environment wrapper."""

    git_url = "https://github.com/Farama-Foundation/Minigrid"
    libname = "minigrid"

    _make_specs = set_gym_backend("gymnasium")(GymEnv._make_specs)

with set_gym_backend(gym):
    assert gym_backend() == gym
    print(gym_backend())
    gym_env = MinigridGymWrapper(gym.make("BabyAI-KeyCorridorS6R3-v0"))

I get the following output with error:

<module 'gymnasium' from '/usr/local/lib/python3.10/dist-packages/gymnasium/__init__.py'>

[/usr/local/lib/python3.10/dist-packages/torchrl/envs/libs/gym.py](https://localhost:8080/#) in _gym_to_torchrl_spec_transform(spec, dtype, device, categorical_action_encoding)
    264         )
    265     else:
--> 266         raise NotImplementedError(
    267             f"spec of type {type(spec).__name__} is currently unaccounted for"
    268         )

NotImplementedError: spec of type BabyAIMissionSpace is currently unaccounted for
vmoens commented 12 months ago

Interesting, what is a BabyAIMissionSpace exactly? Seems like something quite custom no?

kbkartik commented 11 months ago

It is part of Minigrid environments (https://minigrid.farama.org/environments/babyai/)

Sami6720 commented 2 weeks ago

@kbkartik were you able to get MiniGrid to work with torch_rl?