-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_drake-docker.bash
executable file
·47 lines (43 loc) · 1.33 KB
/
run_drake-docker.bash
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
#!/usr/bin/env 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`
# Set docker gpu parameters
if [ ${has_nvidia} -gt 0 ]
then
# 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_GPU_PARAMS=" --device=/dev/dri:/dev/dri"
fi
docker run -ti \
-v "/etc/localtime:/etc/localtime:ro" \
-e DISPLAY=unix$DISPLAY \
-e XAUTHORITY=/tmp/.docker.xauth \
-v /tmp/.X11-unix:/tmp/.X11-unix \
$DOCKER_GPU_PARAMS \
-v "/tmp/.docker.xauth:/tmp/.docker.xauth" \
--privileged \
drake-docker \
"$@"