I'm trying to resurrect some old code, which relies on script with GLFW.
Source code for script can be viewed here
The problem is, I need to run it inside the nvidia docker container (nvcr.io/nvidia/tensorrt:21.06-py3), which is deployed on the server without any Display connected to it. The only way to access server, as usual, is ssh connection.
When calling the script I keep having the same exception:
EXCEPTION: GLFW initialization failed.
, which is the result of
if (glfwInit() != GLFW_TRUE) {
throw std::runtime_error("GLFW initialization failed.");
}
calling glfwGetError(&description)
results in
X11: Failed to open display unix:0
The problem is - there is no default value for $DISPLAY on the server.
I've tried to manually set it on host machine via export DISPLAY=:0
, and then share host x11 socket with running container:
docker run --gpus all -e DISPLAY=unix$DISPLAY -it --rm --shm-size 1G \
-v /tmp/.X11-unix:/tmp/.x11-unix \
<image>
after connecting to the server with x11 forwarding (ssh -X bla@bla
)
But it didn't solve the problem
So my question basically is - how can I make it work? Should I recompile GLFW with some special options, so it will be able to work without set $DISPLAY. Or maybe there is way to invoke mock display in docker container ?
I really need this script to work independently i.e. without any active ssh connections and hence without any x11 forwarding
I added #include <stdexcept>
to facewarp.cpp
.
Or maybe there is way to invoke mock display in docker container?
Yes there is: use a framebuffer (xvfb
) to emulate X11.
🗎 Dockerfile
FROM nvcr.io/nvidia/tensorrt:21.06-py3
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -q && \
apt-get install -y -qq \
g++ \
libglfw3-dev \
libstb-dev \
xvfb
COPY facewarp.cpp .
RUN g++ -I/usr/include/stb/ facewarp.cpp -lGL -lglfw -o facewarp
ENV DISPLAY=:99
ENTRYPOINT []
CMD Xvfb :99 -screen 0 1024x768x16 & ./facewarp