-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·41 lines (36 loc) · 899 Bytes
/
run.sh
File metadata and controls
executable file
·41 lines (36 loc) · 899 Bytes
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
#!/bin/bash
cd $(dirname $0)
cd ../
IMAGE_NAME=$(basename $(pwd) | tr '[:upper:]' '[:lower:]')
USER_ID=`id -u`
GROUP_ID=`id -g`
GROUP_NAME=`id -gn`
USER_NAME=$USER
GPU_OPTION=""
if docker system info | grep -qE '^\s*Runtimes: .*nvidia.*'; then
# Use GPU
GPU_OPTION="--gpus all"
fi
# Check if TTY is available (not in CI environment)
TTY_OPTION=""
if [ -t 0 ] && [ -t 1 ]; then
TTY_OPTION="-it"
fi
docker run \
$TTY_OPTION \
$GPU_OPTION \
--rm \
--shm-size=32g \
--net host \
--env DISPLAY=$DISPLAY \
--env USER_NAME=$USER_NAME \
--env USER_ID=$USER_ID \
--env GROUP_NAME=$GROUP_NAME \
--env GROUP_ID=$GROUP_ID \
--workdir /app \
-v $HOME/.Xauthority:/home/$USER_NAME/.Xauthority:rw \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v ${PWD}:/app \
--name "${IMAGE_NAME}-$(date '+%s')" \
"${IMAGE_NAME}:latest" \
${@:-bash}