-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
FROM rubensa/ubuntu-tini-dev | ||
LABEL author="Ruben Suarez <[email protected]>" | ||
|
||
# If defined, install specified NVIDIA driver version | ||
ARG NVIDIA_VERSION | ||
|
||
# Tell docker that all future commands should be run as root | ||
USER root | ||
|
||
|
@@ -14,14 +17,23 @@ ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update \ | ||
# | ||
# Install software and needed libraries | ||
&& apt-get -y install module-init-tools libglib2.0-bin pulseaudio-utils cups-client x11-utils \ | ||
&& apt-get -y install module-init-tools libglib2.0-bin pulseaudio-utils cups-client x11-utils mesa-utils mesa-utils-extra va-driver-all \ | ||
# | ||
# Assign audio group to non-root user | ||
&& usermod -a -G audio ${USER_NAME} \ | ||
# | ||
# Assign video group to non-root user | ||
&& usermod -a -G video ${USER_NAME} \ | ||
# | ||
# Install NVIDIA drivers | ||
&& if [ ! -z ${NVIDIA_VERSION} ] ; \ | ||
then \ | ||
curl -O http://us.download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_VERSION}/NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run; \ | ||
chmod +x NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run; \ | ||
./NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run --ui=none --no-kernel-module --no-install-compat32-libs --install-libglvnd --no-questions; \ | ||
rm NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run; \ | ||
fi \ | ||
# | ||
# Clean up | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,28 @@ docker build --no-cache \ | |
. | ||
``` | ||
|
||
To make an Nvidia GPU available in the docker container, the following steps have to be taken: | ||
|
||
``` | ||
#!/usr/bin/env bash | ||
# NVidia propietary drivers are needed on host for this to work | ||
NVIDIA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader) | ||
prepare_docker_nvidia_drivers_version() { | ||
# On build, if you specify NVIDIA_VERSION the nvidia specified drivers version are installed | ||
BUILD_ARGS+=" --build-arg NVIDIA_VERSION=$NVIDIA_VERSION" | ||
} | ||
prepare_docker_nvidia_drivers_version | ||
docker build --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
${BUILD_ARGS} \ | ||
. | ||
``` | ||
|
||
## Running | ||
|
||
You can run the container like this (change --rm with -d if you don't want the container to be removed on stop): | ||
|
@@ -80,6 +102,15 @@ prepare_docker_webcam_host_sharing() { | |
prepare_docker_gpu_host_sharing() { | ||
# GPU support (Direct Rendering Manager) | ||
[ -d /dev/dri ] && DEVICES+=" --device /dev/dri" | ||
# VGA Arbiter | ||
[ -c /dev/vga_arbiter ] && DEVICES+=" --device /dev/vga_arbiter" | ||
# Allow nvidia devices access | ||
for device in /dev/nvidia* | ||
do | ||
if [[ -c $device ]]; then | ||
DEVICES+=" --device $device" | ||
fi | ||
done | ||
} | ||
prepare_docker_printer_host_sharing() { | ||
|
@@ -131,25 +162,6 @@ This way, the internal user UID an group GID are changed to the current host use | |
|
||
Functions prepare_docker_dbus_host_sharing, prepare_docker_xdg_runtime_dir_host_sharing, prepare_docker_sound_host_sharing, prepare_docker_webcam_host_sharing, prepare_docker_gpu_host_sharing, prepare_docker_printer_host_sharing, prepare_docker_x11_host_sharing and prepare_docker_hostname_host_sharing allows sharing your host resources with the running container as GUI apps can interact with your host system as they where installed in the host. | ||
|
||
## Setup GPU | ||
|
||
To make an Nvidia GPU available in the docker container, the following steps have to be taken: | ||
|
||
On the host, check your driver version: | ||
|
||
# you might have to install this package: | ||
$ sudo apt-get install mesa-utils | ||
$ glxinfo |grep "OpenGL version" | ||
OpenGL version string: 4.6.0 NVIDIA 390.129 | ||
|
||
In this example, the driver version is "390.129". Now, you have install exactly the same driver in the container: | ||
|
||
export VERSION=390.129 | ||
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/$VERSION/NVIDIA-Linux-x86_64-$VERSION.run | ||
chmod +x NVIDIA-Linux-x86_64-$VERSION.run | ||
apt-get install -y module-init-tools | ||
./NVIDIA-Linux-x86_64-$VERSION.run -a -N --ui=none --no-kernel-module | ||
|
||
## Connect | ||
|
||
You can connect to the running container like this: | ||
|
@@ -203,6 +215,11 @@ You can check X11 running command: | |
xmessage 'Hello, World!' | ||
``` | ||
|
||
Your can chedk GPU acceleration is working running command: | ||
``` | ||
glxgears | ||
``` | ||
|
||
## Stop | ||
|
||
You can stop the running container like this: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# NVidia propietary drivers are needed on host for this to work | ||
NVIDIA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader) | ||
|
||
prepare_docker_nvidia_drivers_version() { | ||
# On build, if you specify NVIDIA_VERSION the nvidia specified drivers version are installed | ||
BUILD_ARGS+=" --build-arg NVIDIA_VERSION=$NVIDIA_VERSION" | ||
} | ||
|
||
prepare_docker_nvidia_drivers_version | ||
|
||
docker build --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
${BUILD_ARGS} \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters