adamrehn / ue4-runtime

Container images for running packaged Unreal Engine projects via the NVIDIA Container Toolkit
https://hub.docker.com/r/adamrehn/ue4-runtime
MIT License
82 stars 26 forks source link

XDG_RUNTIME_DIR not set in the environment. #14

Closed KPicherit closed 1 year ago

KPicherit commented 1 year ago

Hello,

I'm having trouble integrating a packaged unreal (carla more precisely) in a docker image using... basically any UE4 docker base image I found. (ghcr.io/epicgames/unreal-engine:runtime and adamrehn/ue4-runtime:latest)

I can rebuild a functional image from a base Ubuntu release and install nvidia drivers and so on but then the docker image won't work on a machine that don't have the exact same driver version. Plus I know the "good practice" should be to provide the access to host nvidia-driver, but I dont know how to do so.

Basically I'm building my docker image as so:

# syntax=docker/dockerfile:1

 # Tried both with ghrc and adamrehn base images
# FROM ghcr.io/epicgames/unreal-engine:runtime
FROM adamrehn/ue4-runtime:latest

USER root
RUN useradd --create-home --home /home/carla --shell /bin/bash --uid 1001 carla

WORKDIR /home/carla/
USER carla
ENV DIST=/home/carla/Dist/CARLA/LinuxNoEditor

# Copy existing package (running correctly locally) to docker image
COPY --link --chown=1001:1001 ./Dist/CARLA /home/carla/

EXPOSE 2000
EXPOSE 2001
WORKDIR /home/carla/LinuxNoEditor
CMD /bin/bash .CarlaUE4.sh

Then launching the docker through a shell script:

#! /bin/bash

xhost +local:root

image_name="unreal-adamrehn:test"
container_name="unreal_server"

docker run -it --rm \
    --gpus='all,"capabilities=compute,utility,graphics,display"' \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY \
    --privileged \
    --net host \
    --name ${container_name} \
    --device /dev/dri \
    ${image_name} /bin/bash

xhost -local:root

This returns me

carla@lenovo-barth:~/LinuxNoEditor$ ./CarlaUE4.sh 
4.26.2-0+++UE4+Release-4.26 522 0
Disabling core dumps.
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.

I've tried with/without several options to the docker run (remove the --privileged, the mounting of /tmp/.X11-unix...) but nothing changes the error I get. Has someone encountered this error ? Any help would be much appreciated !

Note: It might be Carla-specific (not encountered on UE-only projects), since other Carla users have exeprienced the same issue but I guess it is related to one's config

Note: CarlaUE4.sh script just launches the binary from the UnrealProject root:

#!/bin/sh
UE4_TRUE_SCRIPT_NAME=$(echo \"$0\" | xargs readlink -f)
UE4_PROJECT_ROOT=$(dirname "$UE4_TRUE_SCRIPT_NAME")
chmod +x "$UE4_PROJECT_ROOT/CarlaUE4/Binaries/Linux/CarlaUE4-Linux-Shipping"
"$UE4_PROJECT_ROOT/CarlaUE4/Binaries/Linux/CarlaUE4-Linux-Shipping" CarlaUE4 "$@" 
KPicherit commented 1 year ago

Found out that adding -e SDL_VIDEODRIVER=x11 to the docker run arguments solved the error XDG_RUNTIME_DIR not set. However it appeared not to be what caused the Carla server not to start (some lib where missing both in adamrehn/ue4-runtime:latest and ghcr.io/epicgames/unreal-engine:runtime).

itserror404 commented 1 year ago

Hey, I am facing the same issue, how did you fix it? I did add "-e SDL_VIDEODRIVER=x11" to the docker command but the other error still stays and carla didn't start

KPicherit commented 1 year ago

Hello @itserror404, It appears the XDG_RUNTIME_DIR "error" wasn't what caused the server crash at startup. Installing the following libraries fixed the server for me:

        mesa-vulkan-drivers \
        libxcursor1 \
        libxft2 \
        libxi6 \
        libxinerama1 \
        libxkbcommon0 \
        libxrandr2 \
        libxml2  

Hope this helps