DLR-RM / stable-baselines3

PyTorch version of Stable Baselines, reliable implementations of reinforcement learning algorithms.
https://stable-baselines3.readthedocs.io
MIT License
8.85k stars 1.68k forks source link

[Bug]: Procgen #1823

Open BurgerAndreas opened 8 months ago

BurgerAndreas commented 8 months ago

🐛 Bug

Using Procgen like in the example from the docs website results in:

AssertionError: The algorithm only supports (<class 'gymnasium.spaces.box.Box'>, <class 'gymnasium.spaces.discrete.Discrete'>, <class 'gymnasium.spaces.multi_discrete.MultiDiscrete'>, <class 'gymnasium.spaces.multi_binary.MultiBinary'>) as action spaces but Discrete(15) was provided

To Reproduce

from procgen import ProcgenEnv

from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import VecExtractDictObs, VecMonitor

# ProcgenEnv is already vectorized
venv = ProcgenEnv(num_envs=2, env_name="starpilot")

# To use only part of the observation:
# venv = VecExtractDictObs(venv, "rgb")

# Wrap with a VecMonitor to collect stats and avoid errors
venv = VecMonitor(venv=venv)

model = PPO("MultiInputPolicy", venv, verbose=1)
model.learn(10_000)

Copied from: https://stable-baselines3.readthedocs.io/en/master/guide/examples.html#sb3-and-procgenenv

Relevant log output / Error message

Traceback (most recent call last):
  File "/ssd/robos/xb/sb3_procgen_bug.py", line 15, in <module>
    model = PPO("MultiInputPolicy", venv, verbose=1)
  File "/ssd/robos/xb/venv10/lib/python3.10/site-packages/stable_baselines3/ppo/ppo.py", line 109, in __init__
    super().__init__(
  File "/ssd/robos/xb/venv10/lib/python3.10/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 85, in __init__
    super().__init__(
  File "/ssd/robos/xb/venv10/lib/python3.10/site-packages/stable_baselines3/common/base_class.py", line 180, in __init__
    assert isinstance(self.action_space, supported_action_spaces), (
AssertionError: The algorithm only supports (<class 'gymnasium.spaces.box.Box'>, <class 'gymnasium.spaces.discrete.Discrete'>, <class 'gymnasium.spaces.multi_discrete.MultiDiscrete'>, <class 'gymnasium.spaces.multi_binary.MultiBinary'>) as action spaces but Discrete(15) was provided
Exception ignored in: <function CEnv.__del__ at 0x7f215900c670>

System Info

Checklist

araffin commented 8 months ago

Duplicate of https://github.com/DLR-RM/stable-baselines3/issues/1712

I would appreciate a PR that updates the documentation ;)

nayers17 commented 2 weeks ago

Hi, I'm interested in helping update the documentation for this issue. Is this still needed?

araffin commented 2 weeks ago

yes please =)