Home > Software design >  Vulkan does not detect GPU when running Unity build in Docker container
Vulkan does not detect GPU when running Unity build in Docker container

Time:10-13

Running Unity builds on my PC usually works fine. However when I am trying to run Unity builds within a Docker container I get a segmentation error Segmentation fault (core dumped). I am using Ubuntu 20.04 with an Nvidia GTX1080 and installed all required dependencies like the Nvidia Docker toolkit.

Looking at the logs generated by Unity, it seems that my Nvidia GPU is not detected by Vulkan.

[Vulkan init] SelectPhysicalDevice requestedDeviceIndex=-1 xrDevice=(nil)
[Vulkan init] Physical Device 0xfe9930 [0]: "llvmpipe (LLVM 12.0.0, 256 bits)" deviceType=4 vendorID=10005 deviceID=0
[Vulkan init] Selected physical device (nil)
Caught fatal signal - signo:11 code:1 errno:0 addr:(nil)

By looking at the output of vulkan-info only llvmpipe is detected as physical device.

GPU0:
VkPhysicalDeviceProperties:
---------------------------
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)

In my Dockerfile I set following Nvidia settings

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all

and used --gpus='all,"capabilities=compute,utility,graphics,display"' -e DISPLAY when starting the container.

Also running nvidia-smi within the container works.

 ----------------------------------------------------------------------------- 
| NVIDIA-SMI 450.203.03   Driver Version: 450.203.03   CUDA Version: 11.0     |
|------------------------------- ---------------------- ---------------------- 
| 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  GeForce GTX 108...  Off  | 00000000:15:00.0  On |                  N/A |
| 12%   28C    P8    18W / 250W |    644MiB / 11170MiB |      0%      Default |
|                               |                      |                  N/A |
 ------------------------------- ---------------------- ---------------------- 
                                                                           
 ----------------------------------------------------------------------------- 
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
 ----------------------------------------------------------------------------- 

Any ideas on resolving this problem? Thanks!

CodePudding user response:

I don't know what the problem was, but i found a workaround.

Instead of using ubuntu:20.04 as base image I am using unityci/editor:ubuntu-2022.1.20f1-base-1 in my Dockerfile now.

I am using following settings in a docker compose file to start the container:

unity:
  build: 
    dockerfile: unity.Dockerfile
  volumes:
    - /tmp/.X11-unix:/tmp/.X11-unix
    - ${XAUTHORITY}:${XAUTHORITY}
    - $XDG_RUNTIME_DIR:$XDG_RUNTIME_DIR
  environment:
    - XAUTHORITY
    - DISPLAY
    - XDG_RUNTIME_DIR
    - NVIDIA_VISIBLE_DEVICES=all
    - NVIDIA_DRIVER_CAPABILITIES=all
  deploy:
    resources:
      reservations:
        devices:
          - capabilities: [gpu]
  • Related