forked from uwmisl/primo-similarity-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·46 lines (39 loc) · 1020 Bytes
/
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
#!/bin/bash
host_port=8888
while getopts ":d:s:p:" Option
do
case $Option in
d ) dataset_dir=$OPTARG;;
s ) sequencing_dir=$OPTARG;;
p ) host_port=$OPTARG;;
* ) echo "invalid option specified"; exit 1;;
esac
done
error=0
mounts=""
if [ -d "$dataset_dir" ]; then
mounts="$mounts -v $(realpath $dataset_dir):/tf/open_images"
elif [ -n "$dataset_dir" ]; then
echo "dataset directory is invalid!"
error=1
fi
if [ -d "$sequencing_dir" ]; then
mounts="$mounts -v $(realpath $sequencing_dir):/tf/sequencing"
elif [ -n "$sequencing_dir" ]; then
echo "sequencing directory is invalid!"
error=1
fi
if sudo lsof -i:$host_port > /dev/null; then
echo "host port $host_port is in use, specify a different port with -p"
error=1
fi
if [ $error -ne 0 ]; then
exit 1;
fi
uid=$(id -u $SUDO_USER)
docker run \
--rm -it -u $uid:$uid -p 127.0.0.1:$host_port:8888 --gpus all \
-v $(pwd):/tf/primo \
$mounts \
-e PYTHONPATH=/tf/primo \
primo