Search code examples
dockergpunvidiablender

blender rendering using GPU on docker


I'm geting the following error inside the docker container while trying to run blender/blenderproc (https://download.blender.org/release/Blender3.5/blender-3.5.1-linux-x64.tar.xz ) inside a docker container:

Selecting render devices...
CUDA cuInit: Unknown CUDA error value
Using only the CPU for rendering

My Dockerfile looks like:

FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04

ENV DEBIAN_FRONTEND noninteractive

# setup timezone
RUN echo 'Etc/UTC' > /etc/timezone && \
    ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
    apt-get update && \
    apt-get install -q -y --no-install-recommends tzdata && \
    rm -rf /var/lib/apt/lists/*

# Install necessary dependencies
RUN apt-get update && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt install -y --no-install-recommends \
    curl git lsb-release build-essential software-properties-common \
    cmake python3-pip python3-dev python-is-python3 zlib1g-dev \
    libboost-all-dev libglew-dev libfreeimage-dev libfreeimage3 \
    libxi-dev libxrandr-dev libxxf86vm-dev libopenal-dev libssl-dev \
    libvorbis-dev libogg-dev libjpeg-dev libfreetype6-dev libtiff-dev \
    libwebp-dev libavformat-dev libavcodec-dev libavdevice-dev \
    libavutil-dev libavfilter-dev libswscale-dev libswresample-dev \
    libasound2-dev libx11-xcb-dev libxcb-render0-dev libxcb-shm0-dev \
    libfontconfig1-dev libxkbcommon-x11-dev libsm6 nano

# setup environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

## BlenderProc
WORKDIR /root
RUN git clone https://github.com/DLR-RM/BlenderProc.git
WORKDIR /root/BlenderProc
RUN pip install -e .

## Download textures
RUN echo 'import blenderproc as bproc' | cat - /root/BlenderProc/blenderproc/scripts/download_cc_textures.py > temp && mv temp /root/BlenderProc/blenderproc/scripts/download_cc_textures.py

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

I had already nvidia driver installed and running on my host machine:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.223.02   Driver Version: 470.223.02   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| 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:01:00.0  On |                  N/A |
| N/A   52C    P8     9W /  N/A |    103MiB /  5944MiB |     22%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1863      G   /usr/lib/xorg/Xorg                 32MiB |
|    0   N/A  N/A      2721      G   /usr/lib/xorg/Xorg                 69MiB |
+-----------------------------------------------------------------------------+

Can you please tell me how can I use blender/blenderproc to render on GPU from docker?

P.S: This issue is also reported here


Solution

  • Changing the NVIDIA base image to compatible one has solved my problem:

    FROM nvidia/cuda:11.4.3-cudnn8-runtime-ubuntu20.04