Skip to content

Commit

Permalink
Added support to nvidia runtime through docker-compose
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
diegoferigo committed Aug 3, 2018
1 parent 89b6502 commit 149da01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Development/compose/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Docker Images
DEVELOPMENT_IMAGE=diegoferigo/development
DEVELOPMENT_IMAGE=diegoferigo/development:nvidia
DOCKER_RUNTIME=nvidia
#DOCKER_RUNTIME=runc

# X11 authentication
XSOCK=/tmp/.X11-unix
Expand Down
3 changes: 2 additions & 1 deletion Development/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: '2'
version: '2.3'

services:
development:
image: ${DEVELOPMENT_IMAGE}
runtime: ${DOCKER_RUNTIME}
container_name: development
environment:
# ROS/YARP Variables
Expand Down
28 changes: 16 additions & 12 deletions Development/compose/docker-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ function print_help()
function find_docker_bin()
{
msg "Finding the docker-compose binary"
if [ -x "$(which nvidia-docker-compose)" ] ; then
DOCKERCOMPOSE_BIN=$(which nvidia-docker-compose)
elif [ -x "$(which docker-compose)" ] ; then
if [ -x "$(which docker-compose)" ] ; then
DOCKERCOMPOSE_BIN=$(which docker-compose)
else
err "Docker compose not found! Check your \$PATH"
Expand All @@ -108,7 +106,7 @@ function handle_persistent_resources()
# Persistent files
for file in "${PERSISTENT_FILES[@]}" ; do
if [ ! -f $file ] ; then
mkdir $(dirname $file) || (err2 "Unable to create $(dirname $file)" && exit 1)
mkdir $(dirname $file) || (err2 "Unable to create $(dirname $file)" && exit 1)
touch $file || (err2 "Unable to create $file" && exit 1)
fi
done
Expand All @@ -126,18 +124,24 @@ function docker_workspace()
case $1 in
start|up)
msg "Starting up..."

# Set the X11 authentication resources
msg "Setting up X11 resources"
if [ ! -e $XAUTH ] ; then
msg2 "Creating authentication file"
touch $XAUTH
chmod 777 $XAUTH
else
msg2 "X11 authentication file found"
if [ -e $XAUTH ] ; then
msg2 "Removing old authentication file"
rm -rf $XAUTH
fi

msg2 "Creating authentication file"
touch $XAUTH

msg2 "Granting X11 permissions"
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

if [ $(xauth nlist $DISPLAY | grep -v ffff | wc -l) -gt 1 ] ; then
err "Your system has more than one authentication entry. Exiting" && exit 1
fi
xauth nlist $DISPLAY | grep -v ffff | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
chmod 664 $XAUTH

msg "Setting up the project's resources"
# If a folder is passed as $2, mount it into the host and set it as
# working directory
Expand Down

0 comments on commit 149da01

Please sign in to comment.