forked from moveit/moveit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui-docker
executable file
·56 lines (50 loc) · 1.73 KB
/
gui-docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# This script is used to create and run a docker container with settings for gui interactions
# All arguments to this script will be appended to a docker run command.
# Example command line:
# ./gui-docker -ti --rm moveit/moveit /bin/bash
# XAUTH=/tmp/.docker.xauth
# xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
if [ ! -f /tmp/.docker.xauth ]
then
export XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
fi
# Use lspci to check for the presence of an nvidia graphics card
has_nvidia=`lspci | grep -i nvidia | wc -l`
has_nvidia_docker=`which nvidia-docker > /dev/null 2>&1; echo $?`
# Check if nvidia-docker is avaialble
if [ ${has_nvidia_docker} -eq 0 ] && [ ${has_nvidia} -gt 0 ]
then
DOCKER_COMMAND=nvidia-docker
# Set docker gpu parameters
# check if nvidia-modprobe is installed
if ! which nvidia-modprobe > /dev/null
then
echo nvidia-docker-plugin requires nvidia-modprobe
echo please install nvidia-modprobe
exit -1
fi
# check if nvidia-docker-plugin is installed
if curl -s http://localhost:3476/docker/cli > /dev/null
then
DOCKER_GPU_PARAMS=" $(curl -s http://localhost:3476/docker/cli)"
else
echo nvidia-docker-plugin not responding on http://localhost:3476/docker/cli
echo please install nvidia-docker-plugin
echo https://github.com/NVIDIA/nvidia-docker/wiki/Installation
exit -1
fi
else
DOCKER_COMMAND=docker
DOCKER_GPU_PARAMS=""
fi
DISPLAY="${DISPLAY:-:0}"
${DOCKER_COMMAND} run \
-e DISPLAY=unix$DISPLAY \
-e XAUTHORITY=/tmp/.docker.xauth \
-v "/etc/localtime:/etc/localtime:ro" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "/tmp/.docker.xauth:/tmp/.docker.xauth" \
${DOCKER_GPU_PARAMS} \
$@