diff --git a/examples/PD_controller.ipynb b/examples/PD_controller.ipynb index 38be2edf1..d15ef59cc 100644 --- a/examples/PD_controller.ipynb +++ b/examples/PD_controller.ipynb @@ -6,10 +6,6 @@ "source": [ "# `JAXsim` Showcase: PD Controller\n", "\n", - "\n", - " \"Open\n", - "\n", - "\n", "First, we install the necessary packages and import them." ] }, @@ -23,14 +19,6 @@ "from IPython.display import clear_output, HTML, display\n", "import sys\n", "\n", - "IS_COLAB = \"google.colab\" in sys.modules\n", - "\n", - "# Install JAX and Gazebo\n", - "if IS_COLAB:\n", - " !{sys.executable} -m pip install -U -q jaxsim\n", - " !apt -qq update && apt install -qq --no-install-recommends gazebo\n", - " clear_output()\n", - "\n", "import jax\n", "import jax.numpy as jnp\n", "from jaxsim import logging\n", @@ -141,35 +129,6 @@ "from jaxsim.mujoco.loaders import UrdfToMjcf\n", "\n", "\n", - "if IS_COLAB:\n", - " if subprocess.run(\"ffmpeg -version\", shell=True).returncode:\n", - " !command -v ffmpeg >/dev/null || (apt update && apt install -y ffmpeg)\n", - " clear_output()\n", - "\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", - "\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", - " \"\"\"{\n", - " \"file_format_version\" : \"1.0.0\",\n", - " \"ICD\" : {\n", - " \"library_path\" : \"libEGL_nvidia.so.0\"\n", - " }\n", - " }\n", - " \"\"\"\n", - " )\n", - "\n", "%env MUJOCO_GL=egl\n", "\n", "try:\n", diff --git a/examples/Parallel_computing.ipynb b/examples/Parallel_computing.ipynb index d06aac3ec..a3fc2ed30 100644 --- a/examples/Parallel_computing.ipynb +++ b/examples/Parallel_computing.ipynb @@ -4,11 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# `JAXsim` Showcase: Parallel Simulation of a free-falling body\n", - "\n", - "\n", - " \"Open\n", - "" + "# `JAXsim` Showcase: Parallel Simulation of a free-falling body" ] }, { @@ -29,16 +25,10 @@ "\n", "from IPython.display import HTML, clear_output, display\n", "\n", - "IS_COLAB = \"google.colab\" in sys.modules\n", - "\n", "# Install JAX and Gazebo\n", - "if IS_COLAB:\n", - " !{sys.executable} -m pip install -U -q jaxsim\n", - " !apt -qq update && apt install -qq --no-install-recommends gazebo\n", - " clear_output()\n", - "else:\n", - " # Set environment variable to avoid GPU out of memory errors\n", - " %env XLA_PYTHON_CLIENT_MEM_PREALLOCATE=false\n", + "\n", + "# Set environment variable to avoid GPU out of memory errors\n", + "%env XLA_PYTHON_CLIENT_MEM_PREALLOCATE=false\n", "\n", "import time\n", "from typing import Dict, Tuple\n", diff --git a/examples/README.md b/examples/README.md index c71783ace..8fed061e7 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,23 +4,15 @@ This folder includes a Jupyter Notebook demonstrating the practical usage of JAX ### Examples -- [PD_controller](https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/PD_controller.ipynb) - A simple example demonstrating the use of JAXsim to simulate a PD controller with gravity compensation for a 2-DOF cartpole. -- [Parallel_computing](https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/Parallel_computing.ipynb) - An example demonstrating how to simulate vectorized models in parallel using JAXsim. +- [PD_controller](./PD_controller.ipynb) - A simple example demonstrating the use of JAXsim to simulate a PD controller with gravity compensation for a 2-DOF cartpole. +- [Parallel_computing](./Parallel_computing.ipynb) - An example demonstrating how to simulate vectorized models in parallel using JAXsim. > [!TIP] > Stay tuned for more examples! ## Running the Examples -To execute these examples utilizing JAXsim with hardware acceleration, there are a couple of options available: - -### Option 1: Google Colab (Recommended) - -The simplest way to run the examples is by accessing the provided Google Colab notebook link mentioned above. This will enable you to execute the examples in a hosted environment. - -### Option 2: Local Execution with `pixi` - -For local execution, follow these steps: +To execute these examples utilizing JAXsim with hardware acceleration, you can use [pixi](https://pixi.sh) to run the examples in a local environment: 1. **Install `pixi`:**