{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "MpkYHwCqk7W-" }, "source": [ "\n", "\n", "#
Copyright 2023 DeepMind Technologies Limited.
\n", ">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 http://www.apache.org/licenses/LICENSE-2.0.
\n", ">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.
" ] }, { "cell_type": "markdown", "metadata": { "id": "YvyGCsgSCxHQ" }, "source": [ "# Install MuJoCo, MJX, and Brax" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "id": "Xqo7pyX-n72M" }, "outputs": [], "source": [ "!pip install mujoco\n", "!pip install mujoco_mjx\n", "!pip install brax\n" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "cellView": "form", "id": "IbZxYDxzoz5R" }, "outputs": [], "source": [ "#@title Check if MuJoCo installation was successful\n", "\n", "from google.colab import files\n", "\n", "import distutils.util\n", "import os\n", "import subprocess\n", "if subprocess.run('nvidia-smi').returncode:\n", " raise RuntimeError(\n", " 'Cannot communicate with GPU. '\n", " 'Make sure you are using a GPU Colab runtime. '\n", " 'Go to the Runtime menu and select Choose runtime type.')\n", "\n", "# Add an ICD config so that glvnd can pick up the Nvidia EGL driver.\n", "# This is usually installed as part of an Nvidia driver package, but the Colab\n", "# kernel doesn't install its driver via APT, and as a result the ICD is missing.\n", "# (https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md)\n", "NVIDIA_ICD_CONFIG_PATH = '/usr/share/glvnd/egl_vendor.d/10_nvidia.json'\n", "if not os.path.exists(NVIDIA_ICD_CONFIG_PATH):\n", " with open(NVIDIA_ICD_CONFIG_PATH, 'w') as f:\n", " f.write(\"\"\"{\n", " \"file_format_version\" : \"1.0.0\",\n", " \"ICD\" : {\n", " \"library_path\" : \"libEGL_nvidia.so.0\"\n", " }\n", "}\n", "\"\"\")\n", "\n", "# Configure MuJoCo to use the EGL rendering backend (requires GPU)\n", "print('Setting environment variable to use GPU rendering:')\n", "%env MUJOCO_GL=egl\n", "\n", "try:\n", " print('Checking that the installation succeeded:')\n", " import mujoco\n", " mujoco.MjModel.from_xml_string('