Skip to content

Commit 0991878

Browse files
saran-tcopybara-github
authored andcommitted
Add missing Nvidia ICD file for glvnd to enable GPU rendering on Colab.
PiperOrigin-RevId: 541615331 Change-Id: I50f676548b288aaa4c24f06364f123849c057845
1 parent ccaf796 commit 0991878

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

dm_control/mujoco/tutorial.ipynb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,29 @@
6969
"source": [
7070
"#@title Run to install MuJoCo and `dm_control`\n",
7171
"import distutils.util\n",
72+
"import os\n",
7273
"import subprocess\n",
7374
"if subprocess.run('nvidia-smi').returncode:\n",
7475
" raise RuntimeError(\n",
7576
" 'Cannot communicate with GPU. '\n",
7677
" 'Make sure you are using a GPU Colab runtime. '\n",
7778
" 'Go to the Runtime menu and select Choose runtime type.')\n",
7879
"\n",
80+
"# Add an ICD config so that glvnd can pick up the Nvidia EGL driver.\n",
81+
"# This is usually installed as part of an Nvidia driver package, but the Colab\n",
82+
"# kernel doesn't install its driver via APT, and as a result the ICD is missing.\n",
83+
"# (https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md)\n",
84+
"NVIDIA_ICD_CONFIG_PATH = '/usr/share/glvnd/egl_vendor.d/10_nvidia.json'\n",
85+
"if not os.path.exists(NVIDIA_ICD_CONFIG_PATH):\n",
86+
" with open(NVIDIA_ICD_CONFIG_PATH, 'w') as f:\n",
87+
" f.write(\"\"\"{\n",
88+
" \"file_format_version\" : \"1.0.0\",\n",
89+
" \"ICD\" : {\n",
90+
" \"library_path\" : \"libEGL_nvidia.so.0\"\n",
91+
" }\n",
92+
"}\n",
93+
"\"\"\")\n",
94+
"\n",
7995
"print('Installing dm_control...')\n",
8096
"!pip install -q dm_control\u003e=1.0.12\n",
8197
"\n",

tutorial.ipynb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,29 @@
6969
"source": [
7070
"#@title Run to install MuJoCo and `dm_control`\n",
7171
"import distutils.util\n",
72+
"import os\n",
7273
"import subprocess\n",
7374
"if subprocess.run('nvidia-smi').returncode:\n",
7475
" raise RuntimeError(\n",
7576
" 'Cannot communicate with GPU. '\n",
7677
" 'Make sure you are using a GPU Colab runtime. '\n",
7778
" 'Go to the Runtime menu and select Choose runtime type.')\n",
7879
"\n",
80+
"# Add an ICD config so that glvnd can pick up the Nvidia EGL driver.\n",
81+
"# This is usually installed as part of an Nvidia driver package, but the Colab\n",
82+
"# kernel doesn't install its driver via APT, and as a result the ICD is missing.\n",
83+
"# (https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md)\n",
84+
"NVIDIA_ICD_CONFIG_PATH = '/usr/share/glvnd/egl_vendor.d/10_nvidia.json'\n",
85+
"if not os.path.exists(NVIDIA_ICD_CONFIG_PATH):\n",
86+
" with open(NVIDIA_ICD_CONFIG_PATH, 'w') as f:\n",
87+
" f.write(\"\"\"{\n",
88+
" \"file_format_version\" : \"1.0.0\",\n",
89+
" \"ICD\" : {\n",
90+
" \"library_path\" : \"libEGL_nvidia.so.0\"\n",
91+
" }\n",
92+
"}\n",
93+
"\"\"\")\n",
94+
"\n",
7995
"print('Installing dm_control...')\n",
8096
"!pip install -q dm_control\u003e=1.0.12\n",
8197
"\n",

0 commit comments

Comments
 (0)