forked from milesial/Pytorch-UNet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_docker.sh
executable file
·68 lines (62 loc) · 2.3 KB
/
start_docker.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
PORT=8892 #This is the port alloted to you to view Jupyter notebook
HOST_EXP_DIR=$(pwd) # This is the directory on your computer which becomes visible inside the docker
DOCKER_EXP_DIR=/Experiment # This is the name(path) of the directory inside the docker
HOST_DATA_DIR=/media # This is the directory where permanent data is located
DOCKER_DATA_DIR=/Data # Data directory visible inside docker
GPUS=0 # Number of GPUs you need in the docker
IMAGE='brendancolvert/pytorch-unet:latest' # This is the docker image used to create the container.
NOTEBOOK=false
while getopts ":hi:g:p:n" opt; do
case $opt in
h)
echo "** Available options **" >&2
echo " -h for help " >&2
echo " -g NUM to request NUM GPU units " >&2
echo " -n to request for Jupyter Notebook access, located at http://localhost:$PORT/tree? " >&2
echo " -i IMAGE to request creating docker using IMAGE instead of default $IMAGE" >&2
exit 1
;;
g)
echo " ** $OPTARG GPUS are requested **" >&2
GPUS=$OPTARG
;;
n)
echo " ** Jupyter Notebook requested and is located at http://localhost:$PORT/tree? " >&2
echo "In a separate terminal window, please do: ssh -L $PORT:localhost:$PORT $USER@contijoch-bayern.ucsd.edu **" >&2
NOTEBOOK=true
;;
i)
echo " ** Docker image $OPTARG is requested **" >&2
IMAGE=$OPTARG
;;
p)
echo " ** PORT number $OPTARG is requested **" >&2
PORT=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo " ** Current directory would be reflected inside the docker with as $DOCKER_DIR ** "
if $NOTEBOOK
then
if (("$GPUS" > 0 ))
then
sudo docker run -it -p $PORT:$PORT -v $HOST_EXP_DIR:$DOCKER_EXP_DIR -v $HOST_DATA_DIR:$DOCKER_DATA_DIR --gpus $GPUS $IMAGE jupyter notebook --port=$PORT --no-browser --ip='0.0.0.0' --allow-root
else
sudo docker run -it -p $PORT:$PORT -v $HOST_EXP_DIR:$DOCKER_EXP_DIR -v $HOST_DATA_DIR:$DOCKER_DATA_DIR $IMAGE jupyter notebook --port=$PORT --no-browser --ip='0.0.0.0' --allow-root
fi
else
if (("$GPUS" > 0 ))
then
sudo docker run -it -v $HOST_EXP_DIR:$DOCKER_EXP_DIR -v $HOST_DATA_DIR:$DOCKER_DATA_DIR --gpus $GPUS $IMAGE bash
else
sudo docker run -it -v $HOST_EXP_DIR:$DOCKER_EXP_DIR -v $HOST_DATA_DIR:$DOCKER_DATA_DIR $IMAGE bash
fi
fi