Running Nice DCV inside a singularity container and launching it through open ondemand

I am having trouble running dcv inside a singularity container. Would really appreciate any help I could on this

this is my def file

Bootstrap: docker
From: nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04
%post
export DEBIAN_FRONTEND=noninteractive
apt update && apt upgrade -y
# Install essential dependencies
apt install -y --no-install-recommends
wget xorg openbox mesa-utils
libglvnd-dev dbus-x11 udev pulseaudio
xauth gstreamer1.0-plugins-base
xserver-xorg-core

apt-get install -y xvfb mesa-utils xorg

echo "allowed_users = anybody" > /etc/X11/Xwrapper.config

apt install -y \
    libva-drm2 \
    libva2 \
    libva-x11-2 \
    vainfo \
    i965-va-driver

apt-get install -y xfce4 xfce4-goodies
apt-get install -y \
    udev \
    usbutils \
    libusb-1.0-0

Install missing GTK dependencies

apt-get install -y \
    libgtk-3-0 \
    libgtk-3-bin \
    libgtk-3-common \
    adwaita-icon-theme \
    gnome-themes-standard

apt install -y \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav

apt install -y \
    libnvidia-compute-550 \
    libnvidia-gl-550 \
    libnvidia-encode-550 \
    libnvidia-decode-550 \
    libnvidia-fbc1-550 \
    nvidia-utils-550


apt install --reinstall -y libdbus-1-3 dbus dbus-x11

Configure pulseaudio in container

mkdir -p /etc/pulse
echo "default-server = unix:/tmp/pulse-native" > /etc/pulse/client.conf
echo "autospawn = no" >> /etc/pulse/client.conf

echo "exec startxfce4" > /etc/X11/Xsession.d/99custom-session

# Install NICE DCV Server
wget https://d1uj6qtbmh3dt5.cloudfront.net/2024.0/Servers/nice-dcv-2024.0-18131-ubuntu2204-x86_64.tgz
tar -xzf nice-dcv-*.tgz
cd nice-dcv-*/ && apt install -y ./*.deb

%environment
export DISPLAY=:0
export XAUTHORITY=/tmp/.Xauthority
export XDG_RUNTIME_DIR=/tmp/dcv-runtime
export GST_PLUGIN_SCANNER=/usr/lib/x86_64-linux-gnu/gstreamer-1.0/gst-plugin-scanner
export LD_LIBRARY_PATH=“/usr/lib/x86_64-linux-gnu:/usr/lib/nvidia:$LD_LIBRARY_PATH”
export PULSE_SERVER=unix:/tmp/pulse-native

I am using this command to start the container
sudo singularity run --nv
–bind /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
–bind /home:/home
–bind /dev/dri:/dev/dri
–bind /run/udev:/run/udev
–bind /tmp/.X11-unix:/tmp/.X11-unix
–bind $HOME/.Xauthority:/home/ubuntu/.Xauthority
–bind /usr/lib64:/usr/lib64
–bind /usr/share/icons:/usr/share/icons
–bind /usr/share/fonts:/usr/share/fonts
–bind /var/run/dbus:/var/run/dbus
–bind /etc/pam.d:/etc/pam.d
–bind /etc/passwd:/etc/passwd
–bind /etc/shadow:/etc/shadow
–bind /etc/group:/etc/group
–bind /usr/lib/x86_64-linux-gnu/libdbus-1.so.3:/usr/lib/x86_64-linux-gnu/libdbus-1.so.3
–bind /run/user:/run/user
–bind /usr/bin/dbus-launch:/usr/bin/dbus-launch
–bind /etc/X11/xorg.conf:/etc/X11/xorg.conf
–bind /tmp:/tmp
–bind /tmp/.X11-unix
–bind /dev/shm:/dev/shm
–bind /dev/nvidiactl:/dev/nvidiactl
–bind /dev/nvidia-uvm:/dev/nvidia-uvm
–bind /etc/dbus-1:/etc/dbus-1
–bind /usr/lib/x86_64-linux-gnu/libpcre.so.3.13.3:/usr/lib/x86_64-linux-gnu/libpcre.so.3.13.3
–bind /usr/lib/x86_64-linux-gnu/libpcre.so.3:/usr/lib/x86_64-linux-gnu/libpcre.so.3
–bind /usr/lib/x86_64-linux-gnu/libdbus-1.so.3:/usr/lib/x86_64-linux-gnu/libdbus-1.so.3
–bind /usr/lib/x86_64-linux-gnu/libdbus-1.so.3.19.13:/usr/lib/x86_64-linux-gnu/libdbus-1.so.3.19.13
–bind /dev/nvidia0:/dev/nvidia0
–env LD_LIBRARY_PATH=/opt/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
–env GTK_THEME=HighContrast
–env DISPLAY=:0
–env NO_AT_BRIDGE=1
–env XDG_RUNTIME_DIR=/tmp/runtime-$(id -u)
–env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
dcv.sif

inside the container I am running
dcvserver --create-session test --owner=ubuntu

I get this error
2025-02-16 16:44:05,284577 [ 2333:2333 ] WARN agent-controller - Unable to access the X server

At a glance, I’m wondering why you’re running as sudo. Seems like you’d want a regular user.

Secondly I’d use --env DISPLAY=$DISPLAY as you should have already had one allocated to you (the real user, not root).

Lastly I’d probably try to clean up your bind mounts to reduce the possibility that one or more is incorrect or requires more (like the entire /etc directory or similar).

I modified the run command
singularity run --nv
–bind /run/dbus/system_bus_socket
–bind /home:/home
–bind /dev/dri:/dev/dri
–bind /run/udev:/run/udev
–bind /tmp/.X11-unix:/tmp/.X11-unix
–bind $HOME/.Xauthority:/home/$(whoami)/.Xauthority
–bind /var/run/dbus:/var/run/dbus
–bind /etc/pam.d:/etc/pam.d
–bind /etc/passwd:/etc/passwd
–bind /etc/shadow:/etc/shadow
–bind /etc/group:/etc/group
–bind /sys/class/drm:/sys/class/drm
–bind /tmp:/tmp
–bind /dev/shm:/dev/shm
–bind /dev/nvidiactl:/dev/nvidiactl
–bind /dev/nvidia-uvm:/dev/nvidia-uvm
–bind /dev/nvidia0:/dev/nvidia0
–env LD_LIBRARY_PATH=/opt/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
–env GTK_THEME=HighContrast
–env DISPLAY=:0
–env NO_AT_BRIDGE=1
–env XDG_RUNTIME_DIR=/run/user/$(id -u)
–env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
dcv.sif

but it won’t let me login if I run it without sudo. I think some of the binds are failing.
For now I am trying to set the display manually.
Has anyone been able to do it successfully and can share the steps that would be great.

Hi Jeff,
I figured it out. I was able to run DCV inside a singularity container. One issue that I am facing right now is that. This command-
sudo singularity run --nv
–security=overlay
–bind /home:/home
–bind /etc/passwd:/etc/passwd
–bind /etc/shadow:/etc/shadow
–bind /tmp/.X11-unix:/tmp/.X11-unix
–bind /run:/run
–bind /var/run/dbus:/var/run/dbus
–bind /sys/fs/cgroup:/sys/fs/cgroup
–bind /dev/dri:/dev/dri
–bind $HOME/.Xauthority:/tmp/.Xauthority
–bind /etc/X11:/etc/X11
–bind /usr/share/X11:/usr/share/X11
–bind /var/log:/var/log
–env DISPLAY=:0
dcv.sif

works well and I am able to authenticate.

But my requirement is to run the above command without sudo and make the authentication work. But it won’t let me do it.
I have set a password for ubuntu user in the system and trying to authenticate using that.
Any adivce from your side?

I don’t know what DCV is or why it needs authentication. Can you tell me what that program is?

So basically you can install nice dcv on any server and users can create a dcv session. NICE DCV has a web portal where those users can login and once they login they get GUI view inside that server. It is remote desktop visualisation tool.