Skip to content

Commit

Permalink
Remove any reference to Colab in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed May 15, 2024
1 parent d7cfcc6 commit 13ec38e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 66 deletions.
41 changes: 0 additions & 41 deletions examples/PD_controller.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"source": [
"# `JAXsim` Showcase: PD Controller\n",
"\n",
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/PD_controller.ipynb\">\n",
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
"</a>\n",
"\n",
"First, we install the necessary packages and import them."
]
},
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 4 additions & 14 deletions examples/Parallel_computing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# `JAXsim` Showcase: Parallel Simulation of a free-falling body\n",
"\n",
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/Parallel_computing.ipynb\">\n",
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
"</a>"
"# `JAXsim` Showcase: Parallel Simulation of a free-falling body"
]
},
{
Expand All @@ -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",
Expand Down
14 changes: 3 additions & 11 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:**

Expand Down

0 comments on commit 13ec38e

Please sign in to comment.