NICE DCV Docker Container Ubuntu

0

I am trying to setup a GUI-less docker container using this guide: https://www.ni-sp.com/nice-dcv-in-containers/#nice-dcv-container-with-nvidia-gpu The container will run a vtk render window that should be streamed to the NICE DCV web-client SDK.

The application we are going to run, however, requires Ubuntu 20.04 due to some dependencies and build pipelines. So I am currently trying to figure out how to get the docker container running with Ubuntu as OS with Nvidia drivers. The host OS is also Ubuntu 20.04 (running on g4dn.xlarge EC2 instance) and the provided dcv-container-build.sh script handles the setup of the host. This script has not been changed.

While the DCV server itself works and I can connect to it, the XServer itself cannot find the display.

Running sudo DISPLAY=:0 XAUTHORITY=$(ps aux | grep "X.*\-auth" | grep -v grep | sed -n 's/.*-auth \([^ ]\+\).*/\1/p') xhost | grep "LOCAL:$" returns xhost: unable to open display ":0"

Running xhost + on the host results in xhost: unable to open display ""

Nvidia-smi works and the driver 510.85.02 is installed on host and container.

dcvgldiag returns:


ERROR (1/3)

  Cannot ping 'ip-10-1-2-7'.

  Please, check you network configuration.


ERROR (2/3)

  Cannot find a running 3D X Server [:0]

  Please, make sure the X process is started. Try switching to runlevel 3 and back to runlevel 5.


ERROR (3/3)

  Cannot start a temporary 3D X Server on display :0

  Please, check the X logs for display 0.

The ping check does not work because ping is not is not installed, so that can be ignored for now.

I have adapted the provided Dockerfile/scripts the following way:

Dockerfile:

# BASE IMAGE WITH NVIDIA DRIVERS, XSERVER AND NICE DCV
# ===============================================================

FROM ubuntu:20.04 as dcv

USER root

# Prepare the container to run systemd inside
ENV container docker

# Install tools
#RUN yum -y install tar vim firewalld file wget kmod

RUN apt-get update -y&&\
	apt-get install -y tar vim wget kmod software-properties-common apt-transport-https sudo pciutils kmod ca-certificates xz-utils && \
	apt-get update
		   
RUN apt update && apt upgrade && apt install curl -y


# install mesa
RUN add-apt-repository ppa:kisak/turtle -y && \
	apt update && \
	apt upgrade -y

RUN apt-get install -y mesa-utils

# Install X server
RUN apt-get -y install xauth xserver-xorg-core xserver-xorg xorg xorg openbox x11-utils xfonts-base xterm libxvmc-dev libxatracker-dev xvattr

# Install Nvidia Driver, configure Xorg, install NICE DCV server
ENV NVIDIA_VISIBLE_DEVICES all
# ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_DRIVER_CAPABILITIES all
ADD NVIDIA-installer.run /tmp/NVIDIA-installer.run
# RUN wget -q http://us.download.nvidia.com/XFree86/Linux-x86_64/430.26/NVIDIA-Linux-x86_64-430.26.run -O /tmp/NVIDIA-installer.run 
RUN  bash /tmp/NVIDIA-installer.run --accept-license \
			      --install-libglvnd \
                              --no-questions --no-kernel-module-source \
			      --no-nvidia-modprobe --no-kernel-module \
			      --disable-nouveau \
                              --no-backup \
                              --ui=none \
 && rm -f /tmp/NVIDIA-installer.run \
 && nvidia-xconfig --preserve-busid --enable-all-gpus -connected-monitor=DFP-0,DFP-1,DFP-2,DFP-3

RUN wget https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY && \
	gpg --import NICE-GPG-KEY

# TODO remove install files
RUN wget https://d1uj6qtbmh3dt5.cloudfront.net/2022.2/Servers/nice-dcv-2022.2-13907-ubuntu2004-x86_64.tgz && \
	tar -xvzf nice-dcv-2022.2-13907-ubuntu2004-x86_64.tgz && cd nice-dcv-2022.2-13907-ubuntu2004-x86_64 && \
	apt install ./nice-dcv-server_2022.2.13907-1_amd64.ubuntu2004.deb -y && \
	apt install ./nice-dcv-web-viewer_2022.2.13907-1_amd64.ubuntu2004.deb -y && \
	usermod -aG video dcv && \
	apt install ./nice-xdcv_2022.2.481-1_amd64.ubuntu2004.deb -y && \
	DEBIAN_FRONTEND=noninteractive apt install ./nice-dcv-gl_2022.2.983-1_amd64.ubuntu2004.deb -y && \
	apt install ./nice-dcv-simple-external-authenticator_2022.2.198-1_amd64.ubuntu2004.deb -y

# Define the dcvserver.service
COPY dcvserver.service /usr/lib/systemd/system/dcvserver.service

# Copy the NICE DCV license file 
COPY license.lic /etc/dcv/license.lic

# Send Notification message DCV session ready
COPY send_dcvsessionready_notification.sh /usr/local/bin/

# Open required port on firewall, create test user, send notification, start DCV session for the user
COPY startup_script.sh /usr/local/bin

# Start DCV server and initialize level 5
COPY run_script.sh /usr/local/bin/

# Append the startup script to be executed at the end of initialization and fix permissions; Ubuntu does not have a rc.local file
RUN chmod +x "/usr/local/bin/run_script.sh" \
             "/usr/local/bin/send_dcvsessionready_notification.sh" \
             "/usr/local/bin/startup_script.sh"

EXPOSE 8443

CMD ["/usr/local/bin/run_script.sh"]

run_script.sh:

function tailDcvLog {
    echo "Waiting for X and DCV Server to initialize ... "
    echo
    while [[ ! -f /var/log/dcv/server.log ]] ;do
        # echo -n '.'
        sleep 3
    done
    # echo -n '.'
    sleep 3
    # echo " OK"
    # uncomment the following line in case you want to see the DCV server log
    # tail -f -n500 /var/log/dcv/server.log
}

# Disable nouveau
# if [ -f /usr/bin/nvidia-smi -a ! -f /etc/modprobe.d/blacklist.conf ] ; then
#     cat >> /etc/modprobe.d/blacklist.conf  <<EOF
# blacklist nouveau
# options nouveau modeset=0
# EOF
# fi

# Configure the NICE DCV License
ip=`curl --silent http://169.254.169.254/latest/meta-data/local-ipv4 | grep \.`
if [ "$ip" == "" ] ; then
    # We are not on AWS and need a DCV trial license
    cp /etc/dcv/dcv.conf /etc/dcv/dcv.conf.org
    cat /etc/dcv/dcv.conf.org | awk '/#license-file/ {print "license-file = \"/etc/dcv/license.lic\""}; {print}' > /etc/dcv/dcv.conf
    pubip="Public_IP_or_Server_Name"
else
    # on AWS NICE DCV please enable license access to the S3 bucket
    pubip=`curl --silent http://169.254.169.254/latest/meta-data/public-ipv4 | grep \.`
fi
    
# Enable the DCV service 
# res1=`systemctl enable dcvserver 2>&1`

RED='\033[0;31m'; GREEN='\033[0;32m'; GREY='\033[0;37m'; BLUE='\034[0;37m'; NC='\033[0m' 
ORANGE='\033[0;33m'; BLUE='\033[0;34m';
echo
echo -e "${GREEN}##########################################"  
echo "NICE DCV Container starting up ... "
echo -e "##########################################${NC}"  

echo

# Show DCV Server log in case 
tailDcvLog &

# Setup user and DCV session
( sleep 5; /usr/local/bin/startup_script.sh ;

RED='\033[0;31m'; GREEN='\033[0;32m'; GREY='\033[0;37m'; BLUE='\034[0;37m'; NC='\033[0m' 
ORANGE='\033[0;33m'; BLUE='\033[0;34m';
echo
echo -e "${GREEN}###############################################"  
echo "Your NICE DCV Session is ready to login to ... " 
echo -e "###############################################${NC}"  

echo
echo "The default user name is “user” and the password “dcv” (can be adapted in “startup_script.sh”)."
echo
echo "To connect to DCV you have 2 options: "
echo
# echo -e '\e]8;;http://example.com\aThis is a link\e]8;;\a'
echo -e "Web browser: ${GREEN}\e]8;;https://${pubip}:8443\ahttps://${pubip}:8443\e]8;;\a${NC} (you can accept the security exception as there is no SSL certificate installed) – or –"
echo
echo -e "DCV native client for best performance: Enter “${GREEN}${pubip}${NC}” in the connection field (the portable DCV client can be downloaded here: https://download.nice-dcv.com/)"
echo

) &
# echo ">> Exec /usr/sbin/init"
exec /usr/sbin/init 3

startup_script.sh:

exec &>> /var/log/startup_script.log

set -xe
# ps -ef > /tmp/ps.ef

# Check if we have a well configured xorg.conf and create one in case
if [ ! -f /etc/X11/xorg.conf -o "`grep BusID /etc/X11/xorg.conf | grep PCI`" == "" ] ; then
    sleep 5
    echo "Updating the X server configuration ... "
    sudo systemctl isolate multi-user.target
    sleep 1
    # dcvgladmin disable
    nvidia-xconfig --preserve-busid --enable-all-gpus --connected-monitor=DFP-0,DFP-1,DFP-2,DFP-3
    # add  Option         "HardDPMS" "false"
    sed '/^Section "Device"/a \ \ \ \ Option         "HardDPMS" "false"'  /etc/X11/xorg.conf > /tmp/xorg.conf
    mv /tmp/xorg.conf /etc/X11/xorg.conf
    sed '/^Section "Device"/a \ \ \ \ Option         "UseDisplayDevice" "none"'  /etc/X11/xorg.conf > /tmp/xorg.conf
    # mv /tmp/xorg.conf /etc/X11/xorg.conf
    sleep 1
    # dcvgladmin enable
    sudo systemctl isolate graphical.target
    sleep 1
    sudo systemctl enable dcvserver 2>&1
    sudo systemctl restart dcvserver
fi

# AWS="1"


_username="user"
_passwd="dcv"

adduser "${_username}"
echo "${_username}:${_passwd}" |chpasswd
/usr/bin/dcv create-session --type=virtual --storage-root=%home% --owner "${_username}" --user "${_username}" "${_username}session"

And here's the xorg.conf as well in the docker container:


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/mouse"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Option         "UseDisplayDevice" "none"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Tesla T4"
    BusID          "PCI:0:30:0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "ConnectedMonitor" "DFP-0,DFP-1,DFP-2,DFP-3"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Is it possible that i need additional packages/forgot some?

Thanks, Julian

asked a year ago1095 views
3 Answers
1
Accepted Answer

After a lot of trial and error, i found a working solution. Unfortunately, I am not quite clear on what exactly the issue was, but i was able to create a functioning Dockerfile. I suspect I installed some packages in the wrong order or forgot some, leading to the setup not working. Nevertheless, here is a working Dockerfile for Ubuntu:

FROM ubuntu:20.04 as dcv

USER root

ARG DEBIAN_FRONTEND=noninteractive

# Prepare the container to run systemd inside
ENV container docker

# Install tools
RUN apt-get update  && apt upgrade -y &&\
	apt-get install -y \
		tar vim wget kmod software-properties-common apt-transport-https \
		sudo pciutils ca-certificates xz-utils locales curl && \
		apt-get update

# install X Server, Gnome and GL libs/dependencies
RUN apt-get install -y \
		mesa-utils libxvmc-dev libxatracker-dev \
		xserver-xorg-core xserver-xorg xserver-xorg-dev xorg x11-utils xauth xinit  \
		openbox  xfonts-base xterm freeglut3 ubuntu-desktop-minimal gnome-shell gdm3 \
		libglfw3-dev libgles2-mesa-dev libglew-dev glew-utils

# Install Nvidia Driver, configure Xorg, install NICE DCV server
ENV NVIDIA_VISIBLE_DEVICES all
# ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_DRIVER_CAPABILITIES all
ADD NVIDIA-installer.run /tmp/NVIDIA-installer.run
# RUN wget -q http://us.download.nvidia.com/XFree86/Linux-x86_64/430.26/NVIDIA-Linux-x86_64-430.26.run -O /tmp/NVIDIA-installer.run 
RUN  bash /tmp/NVIDIA-installer.run --accept-license \
			      --install-libglvnd \
                              --no-questions --no-kernel-module-source \
			      --no-nvidia-modprobe --no-kernel-module \
			      --disable-nouveau \
                              --no-backup \
                              --ui=none \
 && rm -f /tmp/NVIDIA-installer.run \
 && nvidia-xconfig --preserve-busid --enable-all-gpus -connected-monitor=DFP-0,DFP-1,DFP-2,DFP-3

# Install NICE DCV
RUN mkdir -p /tmp/dcv-inst && \
	cd /tmp/dcv-inst && \
	wget https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY && \
	gpg --import NICE-GPG-KEY && \
	wget https://d1uj6qtbmh3dt5.cloudfront.net/2022.2/Servers/nice-dcv-2022.2-13907-ubuntu2004-x86_64.tgz && \
	tar -xvzf nice-dcv-2022.2-13907-ubuntu2004-x86_64.tgz && cd nice-dcv-2022.2-13907-ubuntu2004-x86_64 && \
	apt install -y \
		./nice-dcv-server_2022.2.13907-1_amd64.ubuntu2004.deb  \
		./nice-dcv-web-viewer_2022.2.13907-1_amd64.ubuntu2004.deb \
		./nice-xdcv_2022.2.481-1_amd64.ubuntu2004.deb \
		./nice-dcv-gl_2022.2.983-1_amd64.ubuntu2004.deb  \
		./nice-dcv-simple-external-authenticator_2022.2.198-1_amd64.ubuntu2004.deb -y && \
	usermod -aG video dcv && \
	rm -rf /tmp/dcv-inst

# Define the dcvserver.service
COPY dcvserver.service /usr/lib/systemd/system/dcvserver.service

# Copy the NICE DCV license file 
COPY license.lic /etc/dcv/license.lic

# Send Notification message DCV session ready
COPY send_dcvsessionready_notification.sh /usr/local/bin/

# Open required port on firewall, create test user, send notification, start DCV session for the user
COPY startup_script.sh /usr/local/bin

# Start DCV server and initialize level 5
COPY run_script.sh /usr/local/bin/

# Init DCV session configuration, start dotnet application
COPY init_session.sh /usr/local/bin

# Configure DCV settings
COPY dcv.conf /etc/dcv

# Append the startup script to be executed at the end of initialization and fix permissions
RUN chmod +x "/usr/local/bin/run_script.sh" \
             "/usr/local/bin/send_dcvsessionready_notification.sh" \
             "/usr/local/bin/startup_script.sh" \
	     "/usr/local/bin/init_session.sh"

EXPOSE 8443

CMD ["/usr/local/bin/run_script.sh"]

The setup is based on the one provided by the official NICE DCV vendor (centos7) and I tried to adapt it. This version is more or less a prototype and it may be possible to reduce the number of packages further, I have not tested that specifically. It's quite possible that there is a number of useless packages included. This setup runs on a Ubuntu EC2 g4dn.xlarge instance.

answered a year ago
  • Great progress!! Congratulations!!

0

Are there any updates to this? Do you have a Github repo of everything I can clone and try myself? I don't see an init_session file for example.

danqAI
answered a year ago
  • Depending on your OS and instance you can use this guide: https://www.ni-sp.com/nice-dcv-in-containers/#nice-dcv-container-with-nvidia-gpu . A session init file is typically not needed as usually the standard X session startup works well - depends on your use case.

  • the init_session file handles startup stuff for our internal specific usecase, but is not needed, I just copy pasted the whole script essentially. I currently have no plans to upload to github, as our current docker file incorporates project related stuff as well, so I would have to clean that up. One thing I would like to add, however, is the fact that on the host machine you probably need to install the following packages: gdm3 xorg openbox Otherwise the container is unable to correctly start. Don't forget to run systemctl start gdm3

0

Hello,

As per the documentation below, if the command does not return LOCAL:, local users doesn't have access to the X server. Run the following commands to restart the X server, and to disable and re-enable DCV GL:

https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux-checks.html#checks-xserver

$ sudo systemctl isolate multi-user.target

$ sudo dcvgladmin disable

$ sudo dcvgladmin enable

$ sudo systemctl isolate graphical.target

However, if you still experience an issues after running the above commands, you may review server logs located at "/var/log/dcv/server.log" to identify any specific errors.

You may refer the following documentation to check the available logs: https://docs.aws.amazon.com/dcv/latest/adminguide/troubleshooting-logs.html

Additionally, you may also perform the following checks on the system to ensure the installation is working or not.

- Confirm NVIDIA drivers are installed and functional:

    $ nvidia-smi -q | head

- Check if there is a display manager installed:

    $ cat /etc/X11/default-display-manager

- Verify if display manager is running:

    LightDm

    $ service lightdm status

    GDM3

    $ service gdm status

- Check for errors in display manager log files;

     /var/log/lightdm

 - Check the X server is running:

$ ps aux | grep X | grep -v grep

- Check X server and dcv log files;

 /var/log/Xorg.0.log
 /var/log/dcv/server.log
AWS
SUPPORT ENGINEER
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions