This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 36ea17a  [Docker][Vulkan] Allow Vulkan GPU access in docker container. 
(#8784)
36ea17a is described below

commit 36ea17a0d15ce44fdd5d758de2717d75eac4a97e
Author: Lunderberg <[email protected]>
AuthorDate: Thu Aug 19 20:33:43 2021 -0500

    [Docker][Vulkan] Allow Vulkan GPU access in docker container. (#8784)
    
    - The environment variable NVIDIA_DRIVER_CAPABILITIES must include
      "graphics" in order to expose Vulkan drivers to the container.  This
      is added both to Dockerfile.ci_gpu for future image builds, and to
      docker/bash.sh for compatibility with current images.
    
    - The configuration files needed by the vulkan launcher and glvnd must
      be exposed to the container.  These are only included in
      `docker/bash.sh`, as they may vary by host and so cannot be baked
      into the image.
---
 docker/Dockerfile.ci_gpu |  1 +
 docker/bash.sh           | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/docker/Dockerfile.ci_gpu b/docker/Dockerfile.ci_gpu
index 1eb13ea..3d0704b 100644
--- a/docker/Dockerfile.ci_gpu
+++ b/docker/Dockerfile.ci_gpu
@@ -83,6 +83,7 @@ RUN bash /install/ubuntu_install_caffe2.sh
 COPY install/ubuntu_install_dgl.sh /install/ubuntu_install_dgl.sh
 RUN bash /install/ubuntu_install_dgl.sh
 
+ENV NVIDIA_DRIVER_CAPABILITIES compute,graphics,utility
 COPY install/ubuntu_install_vulkan.sh /install/ubuntu_install_vulkan.sh
 RUN bash /install/ubuntu_install_vulkan.sh
 
diff --git a/docker/bash.sh b/docker/bash.sh
index 702cfa0..4667f27 100755
--- a/docker/bash.sh
+++ b/docker/bash.sh
@@ -311,10 +311,34 @@ if [[ "${DOCKER_IMAGE_NAME}" == *"gpu"* || 
"${DOCKER_IMAGE_NAME}" == *"cuda"* ]]
         DOCKER_BINARY=docker
         DOCKER_FLAGS+=( --gpus all )
     fi
+
+    # nvidia-docker treats Vulkan as a graphics API, so we need to
+    # request passthrough of graphics APIs.  This could also be set in
+    # the Dockerfile.
+    DOCKER_ENV+=( --env NVIDIA_DRIVER_CAPABILITIES=compute,graphics,utility )
+
+    # But as of nvidia-docker version 2.6.0-1, we still need to pass
+    # through the nvidia icd files ourselves.
+    ICD_SEARCH_LOCATIONS=(
+        # 
https://github.com/KhronosGroup/Vulkan-Loader/blob/master/loader/LoaderAndLayerInterface.md#icd-discovery-on-linux
+        /usr/local/etc/vulkan/icd.d
+        /usr/local/share/vulkan/icd.d
+        /etc/vulkan/icd.d
+        /usr/share/vulkan/icd.d
+        # 
https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md#icd-installation
+        /etc/glvnd/egl_vendor.d
+        /usr/share/glvnd/egl_vendor.d
+    )
+    for filename in $(find "${ICD_SEARCH_LOCATIONS[@]}" -name "*nvidia*.json" 
2> /dev/null); do
+        DOCKER_MOUNT+=( --volume "${filename}":"${filename}":ro )
+    done
+
 else
     DOCKER_BINARY=docker
 fi
 
+
+
 # Pass any restrictions of allowed CUDA devices from the host to the
 # docker container.
 if [[ -n ${CUDA_VISIBLE_DEVICES:-} ]]; then

Reply via email to