vulkaninfo failed to work in docker and did not recognize NVIDIA GPU
Asked Answered
C

0

11

Problem description

When I run vulkaninfo in docker, it complains:

Cannot create Vulkan instance.
This problem is often caused by a faulty installation of the Vulkan driver or attempting to use a GPU that does not support Vulkan.
ERROR at /build/vulkan-tools-1.3.204.0~rc3-1lunarg20.04/vulkaninfo/vulkaninfo.h:649:vkCreateInstance failed with ERROR_INCOMPATIBLE_DRIVER

It seems like this problem was caused by driver, so I run nvidia-smi to check:

Sun Apr 17 03:12:54 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.60.02    Driver Version: 510.60.02    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:68:00.0 Off |                  N/A |
| 32%   37C    P8    12W / 250W |     18MiB / 11264MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1550      G                                      16MiB |
+-----------------------------------------------------------------------------+

It seems the driver works well. And I check the environment variable NVIDIA_DRIVER_CAPABILITIES and run lspci|grep -i vga:

$ echo ${NVIDIA_DRIVER_CAPABILITIES}
all
$ lspci|grep -i vga
19:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)
1a:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)
67:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)
68:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)

If I install mesa-vulkan-drivers, vulkaninfo works fine but does not recognize NVIDIA GPU:

$ apt install mesa-vulkan-drivers
$ vulkaninfo --summary
Devices:
========
GPU0:
        apiVersion         = 4198582 (1.1.182)
        driverVersion      = 1 (0x0001)
        vendorID           = 0x10005
        deviceID           = 0x0000
        deviceType         = PHYSICAL_DEVICE_TYPE_CPU
        deviceName         = llvmpipe (LLVM 12.0.0, 256 bits)
        driverID           = DRIVER_ID_MESA_LLVMPIPE
        driverName         = llvmpipe
        driverInfo         = Mesa 21.2.6 (LLVM 12.0.0)
        conformanceVersion = 1.0.0.0
        deviceUUID         = 00000000-0000-0000-0000-000000000000
        driverUUID         = 00000000-0000-0000-0000-000000000000

Reproduction details

Host system information:

  • OS: Ubuntu 16.04 xenial
  • Kernel: x86_64 Linux 4.4.0-210-generic
  • CPU: Intel Core i9-10940X CPU @ 4.8GHz
  • GPU: NVIDIA GeForce RTX 2080 Ti x 4 (driver 510.60.02)

Docker information:

  • version: 20.10.7
  • nvidia-container-toolkit version: 1.9.0-1

Docker start command:

$ docker run --rm -it \
    --runtime=nvidia \
    -e NVIDIA_DRIVER_CAPABILITIES=all \
    -e NVIDIA_VISIBLE_DEVICES=3 \
    <docker_image_name> /bin/bash

Dockerfile:

FROM nvidia/cudagl:11.4.2-base-ubuntu20.04
ENV NVIDIA_DRIVER_CAPABILITIES compute,graphics,utility
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
    libx11-xcb-dev \
    libxkbcommon-dev \
    libwayland-dev \
    libxrandr-dev \
    libegl1-mesa-dev 
    wget && \
    rm -rf /var/lib/apt/lists/*

RUN wget -O - http://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \
    wget -O /etc/apt/sources.list.d/lunarg-vulkan-focal.list http://packages.lunarg.com/vulkan/lunarg-vulkan-focal.list && \
    apt update && \
    apt install -y vulkan-sdk

EDIT1: I am running ssh on a headless server and I want to do offline rendering in docker.

Court answered 17/4, 2022 at 3:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.