-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·70 lines (56 loc) · 1.45 KB
/
run.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
cd "${BASH_SOURCE%/*}" || exit
if [ -z "$CONTAINER_NAME" ]; then
CONTAINER_NAME="usgoc"
fi
if [ -z "$JUPYTER_PORT" ]; then
JUPYTER_PORT=8888
fi
JUPYTER_TOKEN=${JUPYTER_TOKEN:-$(cat JUPYTER_TOKEN)}
JUPYTER_URL="http://localhost:$JUPYTER_PORT/?token=$JUPYTER_TOKEN"
if [ ! -z "$(docker ps -aqf "name=^$CONTAINER_NAME\$")" ]; then
echo "Environment is already running in container ${CONTAINER_NAME}." >&2
exit 1
fi
TF_FORCE_GPU_ALLOW_GROWTH=true
REBUILD="0"
ARGS="--rm -it"
if [ "$1" == "rebuild" ]; then
REBUILD="1"
if [ "$2" == "detached" ]; then
ARGS="-d"
fi
elif [ "$1" == "detached" ]; then
ARGS="-d"
if [ "$2" == "rebuild" ]; then
REBUILD="1"
fi
fi
if [[ "$(docker images -q usgoc/usgoc:latest 2> /dev/null)" == "" ]]; then
REBUILD="1"
fi
if [ "$REBUILD" == "1" ]; then
echo "Building container..."
docker build . -t usgoc/usgoc -f Dockerfile
fi
echo "Starting Jupyter at ${JUPYTER_URL} ..."
echo ""
mkdir -p logs
mkdir -p evaluations
mkdir -p exported_models
mkdir -p data
mkdir -p plots
mkdir -p mlruns
docker run --gpus all --name $CONTAINER_NAME \
-p $JUPYTER_PORT:8888 \
-p 6006:6006 -p 10666:10666 -p 1234:1234 \
-v $(pwd):/app \
-v $(pwd)/data:/app/data -v $(pwd)/mlruns:/app/mlruns \
$ARGS \
-u $(id -u):$(id -g) \
--add-host=host.docker.internal:host-gateway \
-e "JUPYTER_TOKEN=$JUPYTER_TOKEN" \
-e TF_FORCE_GPU_ALLOW_GROWTH=$TF_FORCE_GPU_ALLOW_GROWTH \
-e "USER=$USER" \
-e "PROJECT_ROOT=/app" \
usgoc/usgoc