-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Update Gymnasium to v1.0.0 #1837
Conversation
There are only two main issues to resolve + need to rewrite
|
The CI seems to have failed due to reasons unrelated to the version change |
Thanks for the PR =)
if possible (and if not too hacky), I would add backward compat changes to handle both gymnasium 0.29 and 1.x. |
No worries, all the errors seem expected and no unexpected bugs are found
I believe the changes made should be backward compatible. Just updating VecRecordEnv needs to be fully updated / rewritten |
Assuming the Environment which used |
I'm talking about allowing people to use 0.29 with SB3.
mmh, I would double check the |
If the code works with 1.0.0a1 then it will work with 0.29 but possibly not the other way around |
@araffin I believe I have fixed all the issues except for updating |
Currently, there is only one active dev (me...), Quentin (@qgallouedec ) is helping me with answering questions and doing code reviews, for the rest, we have to rely on the community. In the meantime, you could try running tests in SB3 contrib and RL Zoo with this branch, that should unveil other bugs/issues. |
i tested this: (from https://stable-baselines3.readthedocs.io/en/master/guide/examples.html#record-a-video) import gymnasium as gym
from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv
env_id = "CartPole-v1"
video_folder = "logs/videos/"
video_length = 100
vec_env = DummyVecEnv([lambda: gym.make(env_id, render_mode="rgb_array")])
obs = vec_env.reset()
# Record the video starting at the first step
vec_env = VecVideoRecorder(vec_env, video_folder,
record_video_trigger=lambda x: x == 0, video_length=video_length,
name_prefix=f"random-agent-{env_id}")
vec_env.reset()
for _ in range(video_length + 1):
action = [vec_env.action_space.sample()]
obs, _, _, _ = vec_env.step(action)
# Save the video
vec_env.close() and I get this error python test.py
Traceback (most recent call last):
File "/home/intelligence-lab-pc4/Documents/kalli/test_mjc3/test.py", line 17, in <module>
vec_env.reset()
File "/home/intelligence-lab-pc4/Documents/kalli/test_mjc3/stable-baselines3/stable_baselines3/common/vec_env/vec_video_recorder.py", line 66, in reset
self.start_video_recorder()
File "/home/intelligence-lab-pc4/Documents/kalli/test_mjc3/stable-baselines3/stable_baselines3/common/vec_env/vec_video_recorder.py", line 78, in start_video_recorder
self.video_recorder.capture_frame()
^^^^^^^^^^^^^^^^^^^
File "/home/intelligence-lab-pc4/Documents/kalli/test_mjc3/stable-baselines3/stable_baselines3/common/vec_env/base_vec_env.py", line 420, in __getattr__
return self.getattr_recursive(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/intelligence-lab-pc4/Documents/kalli/test_mjc3/stable-baselines3/stable_baselines3/common/vec_env/base_vec_env.py", line 445, in getattr_recursive
attr = getattr(self.venv, name)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DummyVecEnv' object has no attribute 'video_recorder' i am using |
@Kallinteris-Andreas Yes, this is the only part of the PR that still needs to be done. |
Feel free to ping me if necessary |
If I understand correctly, SB3 has its only vector environments, |
There are different things blocking:
|
|
we don't: #1837 (comment) |
SB3 doesn't use Gymnasium's |
I've opened two other PR:
and integrated the video recorder inside the unit tests are passing except for trained agents in the RL Zoo (new version of envs). What is missing for this PR is to update the changelog. |
Are the unit test failing for the same version of the environments? |
it's just that the env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
I've commented out the lunar lander envs in DLR-RM/rl-baselines3-zoo#475 (i need to update the trained agents), but there is still one failure: |
@pseudo-rnd-thoughts there is another weird bug that just popped with gymnasium v1: https://github.com/DLR-RM/rl-baselines3-zoo/actions/runs/11664748980/job/32475927244?pr=475 The saved inf is no longer the same? |
@araffin Thanks for reporting that. I'm reading the logs, and I'm a bit confused by what is happening. Apologies for not noting this in the release notes. I'm not sure what we do about it now, any thoughts? |
yes, from stable-baselines3/stable_baselines3/common/base_class.py Lines 715 to 716 in 8f0b488
I see, then I need to update the trained agent (save and load it while overriding the obs space). |
Should fixed in DLR-RM/rl-trained-agents@eb1bd43 but in the meantime I found another issue. |
Glad the other issue is solved. For ale-py, I'm surprised this is a new problem. Another user has recently asked for changes to the render size. I will investigate adding an argument for specifying the render window size. |
This PR updates SB3 to Gymnasium v1.0, read the release-notes to see all the changes.
closes #2023
SB3 contrib PR: Stable-Baselines-Team/stable-baselines3-contrib#261
RL Zoo PR: DLR-RM/rl-baselines3-zoo#475
Motivation and Context
Gymnasium is the core API used in SB3, therefore would be helpful for both SB3 to use the latest version and that SB3 provides a great testing ground to check for that the Gymnasium release works as intended.
Types of changes
Checklist
make format
(required)make check-codestyle
andmake lint
(required)make pytest
andmake type
both pass. (required)make doc
(required)Note: You can run most of the checks using
make commit-checks
.Note: we are using a maximum length of 127 characters per line