Skip to content

Commit 943a1ec

Browse files
authored
Merge branch 'main' into warp-rsl
2 parents feb969e + 4df68e7 commit 943a1ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7523
-106
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## Next release
5+
## [0.1.0] - 2026-01-07
66

77
- Pass through the [MuJoCo Warp](https://github.com/google-deepmind/mujoco_warp)
88
(MjWarp) implementation to MJX, so that MuJoCo Playground environments can
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
1616
- Update AutoResetWrapper to allow full resets on done. Fixes #179. Also
1717
provides a means for doing curriculum learning via
1818
`state.info['AutoResetWrapper_done_count']`, see #140.
19+
- Update dependencies to use `mujoco>=3.4` and `warp-lang>=1.11`.
1920

2021
## [0.0.5] - 2025-06-23
2122

README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Features include:
1616
For more details, check out the project [website](https://playground.mujoco.org/).
1717

1818
> [!NOTE]
19-
> We now support training with both the MuJoCo MJX JAX implementation, as well as the [MuJoCo Warp](https://github.com/google-deepmind/mujoco_warp) implementation at HEAD. See MuJoCo 3.3.5 [release notes](https://mujoco.readthedocs.io/en/stable/changelog.html#version-3-3-5-august-8-2025) under `MJX` for more details.
19+
> We now support training with both the MuJoCo MJX JAX implementation, as well as the [MuJoCo Warp](https://github.com/google-deepmind/mujoco_warp) implementation at HEAD. See this [discussion post](https://github.com/google-deepmind/mujoco_playground/discussions/197) for more details.
2020
2121
## Installation
2222

@@ -26,34 +26,50 @@ You can install MuJoCo Playground directly from PyPI:
2626
pip install playground
2727
```
2828

29-
> [!WARNING]
30-
> The `playground` release may depend on pre-release versions of `mujoco` and
31-
> `warp-lang`, in which case you can try `pip install playground
32-
> --extra-index-url=https://py.mujoco.org
33-
> --extra-index-url=https://pypi.nvidia.com/warp-lang/`.
34-
> If there are still version mismatches, please open a github issue, and install
35-
> from source.
29+
> [!IMPORTANT]
30+
> We recommend users to install [from source](#from-source) to get the latest features and bug fixes from MuJoCo.
3631
37-
### From Source
32+
### <a id="from-source">From Source</a>
3833

3934
> [!IMPORTANT]
4035
> Requires Python 3.10 or later.
4136
4237
1. `git clone git@github.com:google-deepmind/mujoco_playground.git && cd mujoco_playground`
4338
2. [Install uv](https://docs.astral.sh/uv/getting-started/installation/), a faster alternative to `pip`
44-
3. Create a virtual environment: `uv venv --python 3.11`
39+
3. Create a virtual environment: `uv venv --python 3.12`
4540
4. Activate it: `source .venv/bin/activate`
46-
5. Install CUDA 12 jax: `uv pip install -U "jax[cuda12]"`
47-
* Verify GPU backend: `python -c "import jax; print(jax.default_backend())"` should print gpu
48-
6. Install playground: `uv pip install -e ".[all]"`
49-
7. Verify installation (and download Menagerie): `python -c "import mujoco_playground"`
41+
5. Install CUDA 12 jax: `uv pip install -U "jax[cuda12]" --index-url https://pypi.org/simple`
42+
* Verify GPU backend: `python -c "import jax; print(jax.default_backend())"` should print gpu. `unset LD_LIBRARY_PATH` may need to be run before running this command.
43+
6. Install playground from source: `uv --no-config sync --all-extras`
44+
7. Verify installation: `uv --no-config run python -c "import mujoco_playground; print('Success')"`
45+
* **Note**: Menagerie assets will be downloaded automatically the first time you load a locomotion or manipulation environment. You can trigger this with: `uv --no-config run python -c "from mujoco_playground import locomotion; locomotion.load('G1JoystickFlatTerrain')"`
5046

5147
#### Madrona-MJX (optional)
5248

5349
For vision-based environments, please refer to the installation instructions in the [Madrona-MJX](https://github.com/shacklettbp/madrona_mjx?tab=readme-ov-file#installation) repository.
5450

5551
## Getting started
5652

53+
### Running from CLI
54+
For basic usage, navigate to the repo's directory, install [from source](#from-source) with `jax[cuda12]`, and run:
55+
56+
```bash
57+
train-jax-ppo --env_name CartpoleBalance
58+
```
59+
60+
To train with [MuJoCo Warp](https://github.com/google-deepmind/mujoco_warp):
61+
62+
```bash
63+
train-jax-ppo --env_name CartpoleBalance --impl warp
64+
```
65+
66+
Or with `uv`:
67+
68+
```bash
69+
uv --no-config run train-jax-ppo --env_name CartpoleBalance --impl warp
70+
uv --no-config run train-rsl-ppo --env_name CartpoleBalance --impl warp
71+
```
72+
5773
### Basic Tutorials
5874
| Colab | Description |
5975
|-------|-------------|
@@ -74,15 +90,6 @@ For vision-based environments, please refer to the installation instructions in
7490
| [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/training_vision_1.ipynb) | Training CartPole from Vision |
7591
| [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/training_vision_2.ipynb) | Robotic Manipulation from Vision |
7692

77-
## Running from CLI
78-
> [!IMPORTANT]
79-
> Assumes installation from source.
80-
81-
For basic usage, navigate to the repo's directory and run:
82-
```bash
83-
python learning/train_jax_ppo.py --env_name CartpoleBalance
84-
```
85-
8693
### Training Visualization
8794

8895
To interactively view trajectories throughout training with [rscope](https://github.com/Andrew-Luo1/rscope/tree/main), install it (`pip install rscope`) and run:

learning/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2026 DeepMind Technologies Limited
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Learning scripts for MuJoCo Playground."""

learning/notebooks/locomotion.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"id": "_UbO9uhtBSX5"
3030
},
3131
"source": [
32-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eCopyright 2025 DeepMind Technologies Limited.\u003c/small\u003e\u003c/p\u003e\n",
33-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at \u003ca href=\"http://www.apache.org/licenses/LICENSE-2.0\"\u003ehttp://www.apache.org/licenses/LICENSE-2.0\u003c/a\u003e.\u003c/small\u003e\u003c/small\u003e\u003c/p\u003e\n",
34-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\u003c/small\u003e\u003c/small\u003e\u003c/p\u003e"
32+
"> <p><small><small>Copyright 2025 DeepMind Technologies Limited.</small></p>\n",
33+
"> <p><small><small>Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <a href=\"http://www.apache.org/licenses/LICENSE-2.0\">http://www.apache.org/licenses/LICENSE-2.0</a>.</small></small></p>\n",
34+
"> <p><small><small>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</small></small></p>"
3535
]
3636
},
3737
{
@@ -40,11 +40,11 @@
4040
"id": "dNIJkb_FM2Ux"
4141
},
4242
"source": [
43-
"# Locomotion in The Playground! \u003ca href=\"https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/locomotion.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" width=\"140\" align=\"center\"/\u003e\u003c/a\u003e\n",
43+
"# Locomotion in The Playground! <a href=\"https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/locomotion.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" width=\"140\" align=\"center\"/></a>\n",
4444
"\n",
4545
"In this notebook, we'll walk through a few locomotion environments available in MuJoCo Playground.\n",
4646
"\n",
47-
"**A Colab runtime with GPU acceleration is required.** If you're using a CPU-only runtime, you can switch using the menu \"Runtime \u003e Change runtime type\".\n"
47+
"**A Colab runtime with GPU acceleration is required.** If you're using a CPU-only runtime, you can switch using the menu \"Runtime > Change runtime type\".\n"
4848
]
4949
},
5050
{
@@ -107,7 +107,7 @@
107107
" print('Checking that the installation succeeded:')\n",
108108
" import mujoco\n",
109109
"\n",
110-
" mujoco.MjModel.from_xml_string('\u003cmujoco/\u003e')\n",
110+
" mujoco.MjModel.from_xml_string('<mujoco/>')\n",
111111
"except Exception as e:\n",
112112
" raise e from RuntimeError(\n",
113113
" 'Something went wrong during installation. Check the shell output above '\n",
@@ -142,7 +142,7 @@
142142
"\n",
143143
"# Graphics and plotting.\n",
144144
"print(\"Installing mediapy:\")\n",
145-
"!command -v ffmpeg \u003e/dev/null || (apt update \u0026\u0026 apt install -y ffmpeg)\n",
145+
"!command -v ffmpeg >/dev/null || (apt update && apt install -y ffmpeg)\n",
146146
"!pip install -q mediapy\n",
147147
"import mediapy as media\n",
148148
"import matplotlib.pyplot as plt\n",
@@ -476,11 +476,11 @@
476476
"command = jp.array([x_vel, y_vel, yaw_vel])\n",
477477
"\n",
478478
"state = jit_reset(rng)\n",
479-
"if state.info[\"steps_since_last_pert\"] \u003c state.info[\"steps_until_next_pert\"]:\n",
479+
"if state.info[\"steps_since_last_pert\"] < state.info[\"steps_until_next_pert\"]:\n",
480480
" rng = sample_pert(rng)\n",
481481
"state.info[\"command\"] = command\n",
482482
"for i in range(env_cfg.episode_length):\n",
483-
" if state.info[\"steps_since_last_pert\"] \u003c state.info[\"steps_until_next_pert\"]:\n",
483+
" if state.info[\"steps_since_last_pert\"] < state.info[\"steps_until_next_pert\"]:\n",
484484
" rng = sample_pert(rng)\n",
485485
" act_rng, rng = jax.random.split(rng)\n",
486486
" ctrl, _ = jit_inference_fn(state.obs, act_rng)\n",
@@ -651,7 +651,7 @@
651651
" print(f\"Setting x to {x}\")\n",
652652
" command = jp.array([x, 0, 0])\n",
653653
" state.info[\"command\"] = command\n",
654-
" if state.info[\"steps_since_last_pert\"] \u003c state.info[\"steps_until_next_pert\"]:\n",
654+
" if state.info[\"steps_since_last_pert\"] < state.info[\"steps_until_next_pert\"]:\n",
655655
" rng = sample_pert(rng)\n",
656656
" act_rng, rng = jax.random.split(rng)\n",
657657
" ctrl, _ = jit_inference_fn(state.obs, act_rng)\n",

learning/notebooks/manipulation.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"id": "_UbO9uhtBSX5"
3030
},
3131
"source": [
32-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eCopyright 2025 DeepMind Technologies Limited.\u003c/small\u003e\u003c/p\u003e\n",
33-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at \u003ca href=\"http://www.apache.org/licenses/LICENSE-2.0\"\u003ehttp://www.apache.org/licenses/LICENSE-2.0\u003c/a\u003e.\u003c/small\u003e\u003c/small\u003e\u003c/p\u003e\n",
34-
"\u003e \u003cp\u003e\u003csmall\u003e\u003csmall\u003eUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\u003c/small\u003e\u003c/small\u003e\u003c/p\u003e"
32+
"> <p><small><small>Copyright 2025 DeepMind Technologies Limited.</small></p>\n",
33+
"> <p><small><small>Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <a href=\"http://www.apache.org/licenses/LICENSE-2.0\">http://www.apache.org/licenses/LICENSE-2.0</a>.</small></small></p>\n",
34+
"> <p><small><small>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</small></small></p>"
3535
]
3636
},
3737
{
@@ -40,11 +40,11 @@
4040
"id": "dNIJkb_FM2Ux"
4141
},
4242
"source": [
43-
"# Manipulation in The Playground! \u003ca href=\"https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/manipulation.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" width=\"140\" align=\"center\"/\u003e\u003c/a\u003e\n",
43+
"# Manipulation in The Playground! <a href=\"https://colab.research.google.com/github/google-deepmind/mujoco_playground/blob/main/learning/notebooks/manipulation.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" width=\"140\" align=\"center\"/></a>\n",
4444
"\n",
4545
"In this notebook, we'll walk through a couple manipulation environments available in MuJoCo Playground.\n",
4646
"\n",
47-
"**A Colab runtime with GPU acceleration is required.** If you're using a CPU-only runtime, you can switch using the menu \"Runtime \u003e Change runtime type\".\n"
47+
"**A Colab runtime with GPU acceleration is required.** If you're using a CPU-only runtime, you can switch using the menu \"Runtime > Change runtime type\".\n"
4848
]
4949
},
5050
{
@@ -107,7 +107,7 @@
107107
" print('Checking that the installation succeeded:')\n",
108108
" import mujoco\n",
109109
"\n",
110-
" mujoco.MjModel.from_xml_string('\u003cmujoco/\u003e')\n",
110+
" mujoco.MjModel.from_xml_string('<mujoco/>')\n",
111111
"except Exception as e:\n",
112112
" raise e from RuntimeError(\n",
113113
" 'Something went wrong during installation. Check the shell output above '\n",
@@ -142,7 +142,7 @@
142142
"\n",
143143
"# Graphics and plotting.\n",
144144
"print(\"Installing mediapy:\")\n",
145-
"!command -v ffmpeg \u003e/dev/null || (apt update \u0026\u0026 apt install -y ffmpeg)\n",
145+
"!command -v ffmpeg >/dev/null || (apt update && apt install -y ffmpeg)\n",
146146
"!pip install -q mediapy\n",
147147
"import mediapy as media\n",
148148
"import matplotlib.pyplot as plt\n",

learning/train_jax_ppo.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
from mujoco_playground.config import locomotion_params
4141
from mujoco_playground.config import manipulation_params
4242
import tensorboardX
43-
import wandb
43+
44+
try:
45+
import wandb
46+
except ImportError:
47+
wandb = None
4448

4549

4650
xla_flags = os.environ.get("XLA_FLAGS", "")
@@ -298,6 +302,11 @@ def main(argv):
298302

299303
# Initialize Weights & Biases if required
300304
if _USE_WANDB.value and not _PLAY_ONLY.value:
305+
if wandb is None:
306+
raise ImportError(
307+
"wandb is required for --use_wandb. "
308+
"Install via: pip install wandb"
309+
)
301310
wandb.init(project="mjxrl", name=exp_name)
302311
wandb.config.update(env_cfg.to_dict())
303312
wandb.config.update({"env_name": _ENV_NAME.value})
@@ -530,5 +539,10 @@ def step(carry, _):
530539
print(f"Rollout video saved as 'rollout{i}.mp4'.")
531540

532541

533-
if __name__ == "__main__":
542+
def run():
543+
"""Entry point for uv/pip script."""
534544
app.run(main)
545+
546+
547+
if __name__ == "__main__":
548+
run()

0 commit comments

Comments
 (0)