Add missing Nvidia ICD file for glvnd to enable GPU rendering on Colab.
PiperOrigin-RevId: 541615331 Change-Id: Iff85772bffb245330898e9c2a511d77896bac0cf
This commit is contained in:
committed by
Copybara-Service
parent
ac1f41160d
commit
5e220d43fe
+18
-3
@@ -69,12 +69,28 @@
|
|||||||
"from google.colab import files\n",
|
"from google.colab import files\n",
|
||||||
"\n",
|
"\n",
|
||||||
"import distutils.util\n",
|
"import distutils.util\n",
|
||||||
|
"import os\n",
|
||||||
"import subprocess\n",
|
"import subprocess\n",
|
||||||
"if subprocess.run('nvidia-smi').returncode:\n",
|
"if subprocess.run('nvidia-smi').returncode:\n",
|
||||||
" raise RuntimeError(\n",
|
" raise RuntimeError(\n",
|
||||||
" 'Cannot communicate with GPU. '\n",
|
" 'Cannot communicate with GPU. '\n",
|
||||||
" 'Make sure you are using a GPU Colab runtime. '\n",
|
" 'Make sure you are using a GPU Colab runtime. '\n",
|
||||||
" 'Go to the Runtime menu and select Choose runtime type.')",
|
" '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",
|
"\n",
|
||||||
"# Configure MuJoCo to use the EGL rendering backend (requires GPU)\n",
|
"# Configure MuJoCo to use the EGL rendering backend (requires GPU)\n",
|
||||||
"print('Setting environment variable to use GPU rendering:')\n",
|
"print('Setting environment variable to use GPU rendering:')\n",
|
||||||
@@ -931,8 +947,7 @@
|
|||||||
"accelerator": "GPU",
|
"accelerator": "GPU",
|
||||||
"colab": {
|
"colab": {
|
||||||
"collapsed_sections": [
|
"collapsed_sections": [
|
||||||
"LBAvTJ0xHKy7",
|
"LBAvTJ0xHKy7"
|
||||||
"zcXO67XM5-Kc"
|
|
||||||
],
|
],
|
||||||
"last_runtime": {
|
"last_runtime": {
|
||||||
"build_target": "",
|
"build_target": "",
|
||||||
|
|||||||
+17
-1
@@ -77,12 +77,28 @@
|
|||||||
"from google.colab import files\n",
|
"from google.colab import files\n",
|
||||||
"\n",
|
"\n",
|
||||||
"import distutils.util\n",
|
"import distutils.util\n",
|
||||||
|
"import os\n",
|
||||||
"import subprocess\n",
|
"import subprocess\n",
|
||||||
"if subprocess.run('nvidia-smi').returncode:\n",
|
"if subprocess.run('nvidia-smi').returncode:\n",
|
||||||
" raise RuntimeError(\n",
|
" raise RuntimeError(\n",
|
||||||
" 'Cannot communicate with GPU. '\n",
|
" 'Cannot communicate with GPU. '\n",
|
||||||
" 'Make sure you are using a GPU Colab runtime. '\n",
|
" 'Make sure you are using a GPU Colab runtime. '\n",
|
||||||
" 'Go to the Runtime menu and select Choose runtime type.')",
|
" '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",
|
"\n",
|
||||||
"# Configure MuJoCo to use the EGL rendering backend (requires GPU)\n",
|
"# Configure MuJoCo to use the EGL rendering backend (requires GPU)\n",
|
||||||
"print('Setting environment variable to use GPU rendering:')\n",
|
"print('Setting environment variable to use GPU rendering:')\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user