1

I was trying to use My gym environment with stable baselines, but when I had to update the stable-baselines3 version to 2.0.0a5 my environment did not work anyore, and after loking at several documentation and forum threads I saw I had to start using gymnasium instead of gym to make it work. Now my code does work well in my MacOs and Google Colab. Nevertheless, I have tried to create a virtual environment on a Windows using the same requirement file as in Google Colab (where the code does work), but on Windows I get:

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

The versions I have of gym, gymnasium and stable-baselines3 in both environments is the same, so I do not understand the reason why this happens. My versions are the fllowing:

  • gym --> Version: 0.25.2
  • gymnasium --> Version: 0.28.1
  • stable-baselines3 --> Version: 2.0.0a5
pepito
  • 433
  • 1
  • 3
  • 15

1 Answers1

1

Stable Baselines 3 version >2.0.0 uses Gymnasium. Any version lower than 2.0.0 uses Gym. This error you have suggests that you should be using gym. Downgrade your Stable Baselines 3 to a version <2.0.0, and use gym instead of Gymnasium. That should do the trick.

This question I asked before relates to this question, namely clarifies that there are some inconsistencies when talking about whether to use gym or Gymnasium. Gymnasium is highly preferred, since it is maintained, but not all packages are compatible yet. gym on the other hand, is supported by many packages but is not up to date. The trade off is yours to make, but also based on what you need to work with.

Your error however, suggests that you should use gym, and thus downgrade Stable Baselines 3.

(As a sidenote, I prefer gym 0.26, but that is entirely up to you. This has also to do with the changes made to the agent-environment loop, where the render is in aforementioned version part of the loop)

Lexpj
  • 921
  • 2
  • 6
  • 15