Hello~ I get the following message when running obs in docker. I don’t know why the hardware decoding cannot be performed.
How to rule it out?
My question is, this part will normally show the graphics card device instead of the following
obs-1 | info: Initializing OpenGL…
obs-1 | libEGL warning: DRI2: failed to authenticate
obs-1 | info: Loading up OpenGL on adapter Mesa llvmpipe (LLVM 15.0.7, 256 bits)
obs-1 | info: Command Line Arguments: --startrecording
obs-1 | info: Using EGL/X11
obs-1 | info: CPU Name: Intel(R) Core™ Ultra 5 235
obs-1 | info: CPU Speed: 4699.115MHz
obs-1 | info: Physical Cores: 14, Logical Cores: 14
obs-1 | info: Physical Memory: 63683MB Total, 48392MB Free
obs-1 | info: Kernel Version: Linux 6.11.0-26-generic
obs-1 | info: Distribution: “Ubuntu” “22.04”
obs-1 | info: Window System: X11.0, Vendor: The [X.Org](http://X.Org) Foundation, Version: 1.21.1
obs-1 | info: Qt Version: 6.2.4 (runtime), 6.2.4 (compiled)
obs-1 | info: Portable mode: false
obs-1 | info: OBS 30.2.3 (linux)
obs-1 | info: ---------------------------------
obs-1 | info: ---------------------------------
obs-1 | info: audio settings reset:
obs-1 | samples per sec: 48000
obs-1 | speakers: 2
obs-1 | max buffering: 960 milliseconds
obs-1 | buffering type: dynamically increasing
obs-1 | info: ---------------------------------
obs-1 | info: Initializing OpenGL…
obs-1 | libEGL warning: DRI2: failed to authenticate
obs-1 | info: Loading up OpenGL on adapter Mesa llvmpipe (LLVM 15.0.7, 256 bits)
obs-1 | info: OpenGL loaded successfully, version 4.5 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.3, shading language 4.50
docker compose yml
version: "3.9"
services:
obs:
build: .
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,video,utility,graphics
- OBS_USE_EGL=1
ports:
- "5900:5900" # VNC
devices:
- /dev/nvidia0
- /dev/nvidiactl
- /dev/nvidia-uvm
- /dev/nvidia-modeset
- /dev/nvidia-uvm-tools
privileged: true
deploy:
resources:
reservations:
devices:
- capabilities: [gpu]
shm_size: '1gb'
dockerfile
# 使用 NVIDIA CUDA base image
FROM nvidia/opengl:1.0-glvnd-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Taipei
# RUN sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
# 安裝必要套件
RUN apt-get update &&\
apt-get install -y software-properties-common curl gnupg && \
add-apt-repository ppa:obsproject/obs-studio -y && \
apt-get install -y --no-install-recommends \
obs-studio \
wget \
dbus \
mesa-utils \
x11-xserver-utils \
xserver-xorg-video-dummy \
xserver-xorg-core \
xinit \
libgl1-mesa-glx \
libgl1-mesa-dri \
libnvidia-egl-wayland1 \
obs-studio \
pulseaudio \
dbus-x11 \
x11vnc \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# 建立 xdummy Xorg 配置,解析度 1920x1080
RUN mkdir -p /etc/X11/xorg.conf.d
RUN echo 'Section "Device"\n Identifier "DummyDevice"\n Driver "dummy"\n VideoRam 256000\nEndSection\n\nSection "Monitor"\n Identifier "DummyMonitor"\n HorizSync 28.0-80.0\n VertRefresh 48.0-75.0\nEndSection\n\nSection "Screen"\n Identifier "DummyScreen"\n Device "DummyDevice"\n Monitor "DummyMonitor"\n DefaultDepth 24\n SubSection "Display"\n Depth 24\n Modes "1920x1080"\n EndSubSection\nEndSection\n' > /etc/X11/xorg.conf.d/10-dummy.conf
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,video,utility,graphics
ENV OBS_USE_EGL=1
# 建立使用者
RUN useradd -m obsuser
COPY entrypoint.sh /home/obsuser/entrypoint.sh
RUN chmod +x /home/obsuser/entrypoint.sh \
&& chown obsuser:obsuser /home/obsuser/entrypoint.sh
WORKDIR /home/obsuser
ENTRYPOINT ["/home/obsuser/entrypoint.sh"]
entrypoint.sh
#!/bin/bash
set -e
# 啟動 system dbus
dbus-daemon --system &
# 啟動虛擬 X server(xdummy)
Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile /tmp/xorg.log -config /etc/X11/xorg.conf.d/10-dummy.conf :99 &
export DISPLAY=:99
sleep 5
# 啟動 x11vnc,允許遠端連線(無密碼,-forever 保持連線)
x11vnc -display :99 -nopw -forever -shared &
# 啟動 pulseaudio(依需求可註解)
pulseaudio --start
# 啟動 OBS
obs --startrecording &
# 防止 container 退出,保持運行狀態
wait