Skip to content

Fix PPO tutorial: Add gymnasium support and Mujoco rendering compatibility in Colab #3401

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abhitorch81
Copy link

Fixes #3392

Description

This PR updates the reinforcement_ppo.py tutorial to improve compatibility with Google Colab and future-proof it for gymnasium usage.

Key Changes:

  • Added fallback logic to import gymnasium if available, otherwise fall back to gym
  • Dynamically select InvertedDoublePendulum-v5 or v4 based on the gym version
  • Set MUJOCO_GL=osmesa in Colab/headless environments to avoid OpenGL rendering errors from Mujoco
  • Ensures compatibility with Mujoco v3.1.1 and gymnasium[mujoco]

This makes the tutorial runnable out of the box in Google Colab, with improved robustness across versions.

Checklist

Copy link

pytorch-bot bot commented Jun 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3401

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 448dee8 with merge base 5f17335 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

Hi @abhitorch81!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@abhitorch81 abhitorch81 force-pushed the fix/ppo-mujoco-colab branch from a4cf591 to 448dee8 Compare June 19, 2025 07:20
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - <title> Error in downloading MuJoCo Gymnasium library
2 participants