题意:对于OpenAI Gym,是否有支持它的算法库?
问题背景:
OpenAI has released a new library called Gymnasium which is supposed to replace the Gym library. There are many libraries with implamentations of RL algorithms supporting gym environments, however the interfaces changes a bit with Gymnasium. Are there any libbraries with algorithms supporting Gymnasium? I tried CleanRL, KerasRL, RLib and some others and none of them work, the only way for now is to implement them manually, am I correct?
OpenAI 发布了一个名为 Gymnasium 的新库,旨在取代 Gym 库。有许多库实现了支持 Gym 环境的强化学习算法,但 Gymnasium 的接口稍有变化。有支持 Gymnasium 的算法库吗?我尝试了 CleanRL、KerasRL、RLib 和其他一些库,都无法正常工作,目前唯一的办法是手动实现这些算法,我说得对吗?
问题解决:
Stable Baselines3 doesn't have a release with Gymnasium support yet, but this pull request explains how to install and use it with gymnasium
.
Stable Baselines3 尚未发布支持 Gymnasium 的版本,但这个拉取请求解释了如何安装并与 Gymnasium 一起使用它。
First install the version for that PR:
首先安装该拉取请求的版本:
$ pip install git+https://github.com/carlosluis/stable-baselines3@fix_tests
And assuming you have gymnasium
installed already, you can run:
假设你已经安装了 gymnasium,你可以运行:
# Important step to override `gym` as `gymnasium`.
import sys
import gymnasium
sys.modules["gym"] = gymnasium
# Sample code which works
from stable_baselines3 import PPO
env = gymnasium.make("CartPole-v1", render_mode="rgb_array")
model = PPO("MlpPolicy", env, verbose=1)