forked from DeepCognition/deep-learning-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdls.sh
More file actions
117 lines (99 loc) · 2.94 KB
/
Copy pathdls.sh
File metadata and controls
117 lines (99 loc) · 2.94 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash -e
DATA_DIR=$HOME/.deepcognition/dls/data
PORT_NUM=80
COMPUTE_PORT=81
JUPYTER_PORT=8888
FILEBROWSER_PORT=8880
DOCKER_CMD=/usr/bin/nvidia-docker
RED='\033[1;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'
IMAGE='deepcognition/deep-learning-studio:latest'
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -f $SCRIPT_DIR/EULA.md ]; then
echo License file is missing. Please download the whole package from https://github.com/DeepCognition/deep-learning-studio and try again.
exit 1
fi
if [ ! -f $SCRIPT_DIR/.accepted ]; then
more $SCRIPT_DIR/EULA.md
echo
echo -e -n "Accept this agreement (${GREEN}y${NC}/${RED}n${NC}):"
read response
if [ ! "$response" == "y" ]; then
exit 1
fi
touch $SCRIPT_DIR/.accepted
echo Downloading....
docker pull $IMAGE
fi
usage() {
echo "Usage: $0 [option...] {uninstall|update|start|stop}"
echo
echo " run options:"
echo " -d, --data specify the data directory (absolute path)"
echo " -p, --port specify the deep learning studio port number"
exit 1;
}
uninstall() {
echo -e -n "Do you want to delete the data folder ($DATA_DIR) (${GREEN}y${NC}/${RED}n${NC}):"
read response
if [ ! "$response" == "y" ]; then
rm -rf $DATA_DIR
fi
docker stop deep-learning-studio
docker rm deep-learning-studio
docker rmi $IMAGE
echo Done
}
update() {
echo "Updating..."
docker pull $IMAGE
}
stop () {
docker stop deep-learning-studio
}
run() {
update
if [ ! -f "$DOCKER_CMD" ]; then
echo
echo -e "${RED}nvidia-docker is not installed. Deep learning studio will run in ${GREEN}CPU mode.${NC}"
echo
echo "If your system contains nvidia GPU, you can install nvidia-docker from https://github.com/NVIDIA/nvidia-docker/wiki/Installation "
echo
DOCKER_CMD=docker
fi
if [ ! -d "$DATA_DIR/database" ]; then
mkdir -p $DATA_DIR/database
mkdir $DATA_DIR/keras
fi
options=" -p $PORT_NUM:80 -p $COMPUTE_PORT:80 -p $FILEBROWSER_PORT:8880 -p $JUPYTER_PORT:8888"
options+=" -v $DATA_DIR:/data"
options+=" -v $DATA_DIR/database:/home/app/database"
options+=" -v ${DATA_DIR}/keras:/root/.keras"
docker rm deep-learning-studio 2>/dev/null || true
echo "Starting..."
$DOCKER_CMD run -d $options --name deep-learning-studio $IMAGE
echo Done
echo
echo -e "Go to ${GREEN}http://127.0.0.1:"$PORT_NUM"/app/${NC} to start using Deep Learning Studio"
}
while getopts :d:p: option
do
case "${option}" in
d) DATA_DIR=${OPTARG};;
p) PORT_NUM=${OPTARG}
COMPUTE_PORT=`expr $PORT_NUM + 1`
FILEBROWSER_PORT=`expr $PORT_NUM + 8`
JUPYTER_PORT=`expr $PORT_NUM + 6`
;;
*) usage
esac
done
shift $((OPTIND-1))
case $1 in
update) update;;
run) run;;
start) run;;
stop) stop;;
*) usage
esac