Installing Driveworks within a docker image

For various reasons I have Ubuntu 17.10 installed on my desktop computer. Most of our development and deployment is done using docker containers, so it seemed logical to me to try to install Driveworks in a docker image.

Here is the Docker file I used as a base to work from:

FROM nvidia/cuda:9.0-devel-ubuntu16.04

RUN apt-get update && apt-get install -y \
  libcanberra-gtk3-module \
  x11-utils \
  lsb-core \
  sudo \
  firefox

# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer


USER developer
ENV HOME /home/developer

WORKDIR /home/developer
ADD . /home/developer

CMD bash

I build with

$ nvidia-docker build -t driveworks .

and after putting the run file in current dir (same as the Dockerfile, run with

$ nvidia-docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix driveworks

In the container I then attempt to install using the runfile (strangely the non-silent launcher just doesn’t make progress downloading anything, but the silent launcher does)

developer@2cc7cedacafa:~$ launcher_silent_mode=install development_platform=autochauffeur ./DriveInstall_5.0.5.0L_SDK_b96.run

This downloads everything and then exits the GUI installer without a message explaining the problem.

Has anyone else tried something similar? Any hints or ideas?

Hi Brian.

There are 2 things that needs to be done before running the launcher.

in target file /usr/share/polkit-1/actions/org.freedesktop.policykit.policy
change allow_any,allow_inactive,allow_active to yes

  1. Run /etc/init.d/dbus stop
  2. Run /etc/init.d/dbus start
  3. Run installer

image size will be around 45 gb full install

oh forgot 1 more thing.

RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer
should also add developer to sudo group
RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer && \
    usermod -a -G sudo developer

Hi,

i am trying to do the same, namely trying to put DriveWorks into a Docker Container.
I tried your Dockerfile, but using the canonical docker.io version 1.13.1 (not nvidia-docker).

Following output is produced:

developer@b831a29a0476:~$ ./DriveInstall_5.0.5.0aL_SDK_b19.run
Creating directory _installer
Verifying archive integrity… 100% All good.
Uncompressing DriveInstall 100%

The installation GUI doesn’t pop up, but just ends, without any feedback.

Am i missing something?

I can open firefox normally (firefox crashes at every first time, reopen works)

Are you running with
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix driveworks

Try with theese commands

docker build . -t clean --no-cache

docker run -it --name docker_5.0.5.0 -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/snd:/dev/snd -e DISPLAY=unix:0 --privileged clean

yes, with this command i can open firefox. but with the other one, i got error:

developer@b2f3287beec3:~$ firefox
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Broadway display type not supported: unix:0
Error: cannot open display: unix:0

Are you Running on a macosx machine?

I havent any experience from this.
But main issue is that macosx doesnt run x11

no. My os is Ubuntu 16.04. 64 Bit
Nvidia Driver: 384.111 (GeForce GTX680)

could it be something with docker from docker.io and nvidia-docker? i am looking to install nvidia-docker.

Could be some dependencies. Lemme check when i got my compy

I use non nvidia docker too btw

(firefox:615): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Failed to execute child process "dbus-launch" (No such file or directory)
developer@9ad80a118d18:~$ sudo /etc/init.d/dbus stop
 * Stopping system message bus dbus                                                                                                       [ OK ] 
developer@9ad80a118d18:~$ sudo /etc/init.d/dbus start
 * Starting system message bus dbus                                                                                                       [ OK ] 
developer@9ad80a118d18:~$ ./DriveInstall_5.0.5.0aL_SDK_b19.run 
Creating directory _installer
Verifying archive integrity...  100%   All good.
Uncompressing DriveInstall  100%  
developer@9ad80a118d18:~$

on my system. i have cuda 7.5. I don’t know, wether it has any effect

i found that i need the lib: libgtk-x11-2.0.so.0
so i install it, and the gui pop up.

sudo apt install libgtk2.0-0

Thanks for your help and your Dockerfile.

@stefan.nygren: do i also have to install the graphic driver in the docker container? the given example apps from the SDK could not be opened because of lacking of libcuda.so.1 file.
But when i try to install the same driver version as my host pc, i get errors like this:

Errors were encountered while processing:
nvidia-384
libcuda1-384
nvidia-opencl-icd-384
E: Sub-process /usr/bin/dpkg returned an error code (1)

for other people who also get this problem:
libcuda.so is provided in /usr/local/cuda-9.0/targets/x86_64-linux/lib/stubs.
You can create a symlink and add the folder in LD_LIBRARY_PATH.

After fixing this problem, i got the error: libnvcuvid.so.1 not found.
It seems that this lib is not provided in docker.
One solution is to mount the lib folder in your host pc and add it into LD_LIBRARY_PATH.
For compability you may also have to use libcuda.so.1 from your host pc.

Now i am facing with the problem: WindowGLFW: Failed initialize GLFW. But this is other adventure.

Solution for WindowGLFW problem:
run: xhost +
// xhost + will give access to anybody to connect to your display. I would recommend xhost +local:[hostname or ip]

Now to next problem: Driveworks exception thrown: DW_CUDA_ERROR: TensorRT: Compute capability 5.0 or higher required.

I have picked up Brian’s work and been able to get an image up and running that completes the installation, flash the PX2, and is able to compile and run the DriveWorks samples. This is the complete Dockerfile:

FROM ubuntu:16.04

# Needed to be able to install resolvconf without complaints about /etc/resolv.conf not being accessible
# See: https://github.com/moby/moby/issues/1297#issuecomment-115458690
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections

RUN apt-get update \
    && apt-get install -y \
       chromium-browser \
       dmidecode \
       kmod \
       libcanberra-gtk3-module \
       libgtk2.0-0 \
       lsb-core \
       lsof \
       minicom \
       resolvconf \
       software-properties-common \
       sudo \
       tzdata \
       udev \
       unzip \
       usbutils \
       vim \
       x11-utils \
       xterm \
    && apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*

# Set up time and locale
# /etc/localtime is replaced by an actual file instead of symbolic link,
# otherwise DriveInstall can end up trying to copy the same file to itself
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen && \
    rm /etc/localtime && \
    cp /usr/share/zoneinfo/Etc/UTC /etc/localtime
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8

# You can set these when building the image, with the `--build-args` flag
ARG HOST_UID=1000
ARG HOST_GID=1000

ENV HOST_UID ${HOST_UID}
ENV HOST_GID ${HOST_GID}

RUN useradd --create-home --uid ${HOST_UID} --groups sudo --shell /bin/bash developer \
    && echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer \
    && chmod 0440 /etc/sudoers.d/developer


ENV HOME /home/developer

USER developer
WORKDIR /home/developer

CMD bash

The following script builds an image based on this, and runs DriveInstall in silent mode, including flashing the PX2 if you have it connected to the host through USB A-A:

#!/bin/bash

echo "Building base docker image..."

if ! nvidia-docker build \
              --build-arg HOST_UID=$(id -u) \
              --build-arg HOST_GID=$(id -g) \
              -t driveworks:base .; then
    echo "ERROR: failed building base docker image"
    exit 1
fi

echo "Done"

echo "***** DOWNLOAD DriveInstall AND PLACE THE .run FILE IN $(pwd)"
echo "**"
echo "**    https://developer.nvidia.com/nvidia-drive-downloads"
echo "**"
echo "**    TO BE ABLE TO RUN THE FULL PROCESS INCLUDING FLASHING THE PX2,"
echo "**    HAVE THE PX2 CONNECTED THROUGH USB A-A TO HOST AND TO 10GB ETH PORT,"
echo "**    AND SWITCHED ON"
echo "**"
read -n1 -rp "***** Press any key to continue when done..." key
echo

DRIVE_INSTALL=$(ls DriveInstall*)

if [ "x$DRIVE_INSTALL" == "x" ]; then
    echo "ERROR: DriveInstall not found"
    exit 1
fi

if ! docker run -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
       -v $(pwd):/home/developer \
       -e launcher_silent_mode=install \
       -e development_platform=autochauffeur \
       --privileged \
       --device /dev/ttyUSB0 \
       --device /dev/ttyUSB1 \
       --device /dev/ttyUSB2 \
       --device /dev/ttyUSB3 \
       --device /dev/ttyUSB4 \
       --device /dev/ttyUSB5 \
       --device /dev/ttyUSB6 \
       --device /dev/ttyUSB7 \
       -v /dev/bus/usb:/dev/bus/usb \
       driveworks:base bash -c ./$DRIVE_INSTALL; then
    echo "WARNING: DriveInstall returned an error code, it may be that your Docker image is not complete. If this happened when it got to flashing the PX2 and you don't have it connected, you should be fine."
fi

docker commit $(docker ps -l -q) driveworks:sdk

This results in a docker image tagged driveworks:sdk. The following is a script to run it, ensuring the nvidia drivers and runtime of your host (host-host? :) )are available:

#!/bin/bash

NVIDIA_DRIVER_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | head -n 1 | cut -d '.' -f 1)

docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
       -v $(pwd):/home/developer \
       --privileged \
       --device /dev/ttyUSB0 \
       --device /dev/ttyUSB1 \
       --device /dev/ttyUSB2 \
       --device /dev/ttyUSB3 \
       --device /dev/ttyUSB4 \
       --device /dev/ttyUSB5 \
       --device /dev/ttyUSB6 \
       --device /dev/ttyUSB7 \
       -v /dev/bus/usb:/dev/bus/usb \
       -v /usr/lib/nvidia-${NVIDIA_DRIVER_VERSION}:/usr/lib/nvidia-${NVIDIA_DRIVER_VERSION} \
       -e LD_LIBRARY_PATH=/usr/lib/nvidia-${NVIDIA_DRIVER_VERSION} \
       --runtime=nvidia \
       driveworks:sdk bash

When running, you should be able to read the docs:

chromium-browser /usr/local/driveworks/doc/index.html

And build and run the samples:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release /usr/local/driveworks/samples/
make -j
./src/hello_world/sample_hello_world

Hope that works for you!

Thanks for sharing your experience. I managed to install and run the prebuilt examples in /usr/local/driveworks/bin.
But i just installed packets by hand. I am trying your scripts right now. I will give feedback, if i get any problem.
Thanks again.

Thanks @sandervandijk , your scripts works perfectly. And using raw ubuntu base produces smaller docker image thant nvidia-cuda ubuntu base.