-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_docker.sh
executable file
·48 lines (47 loc) · 1.63 KB
/
run_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
set -e
# 帮助函数
function usage () {
echo -e "\033[32m Usage : \033[0m"
echo -e "\033[32m ------------------------------------------------------------------- \033[0m"
echo "| bash $0 [CONTAINER_NAME]"
echo "| Supported options:"
echo "| PYTORCH_TRAIN_DATASET: dataset path."
echo "| CONTAINER_NAME: container name."
echo -e "\033[32m ------------------------------------------------------------------- \033[0m"
}
while getopts 'h:' opt; do
case "$opt" in
h) usage ; exit 1 ;;
?) echo "unrecognized optional arg : "; $opt; usage; exit 1;;
esac
done
CONTAINER_NAME=mlu_pointpillar
if [ -z $IMAGE_NAME ]; then
echo "please set environment variable IMAGE_NAME."
exit 1
fi
if [ -z $PYTORCH_TRAIN_DATASET ]; then
echo "please set environment variable PYTORCH_TRAIN_DATASET."
exit 1
fi
if [[ $1 != "" ]]; then
CONTAINER_NAME=$1
fi
num=`docker ps -a|grep "$CONTAINER_NAME"|wc -l`
echo $num
echo $CONTAINER_NAME
if [ 0 -eq $num ]; then
# change the `-v /your/data:/your/data` and `-v /your/ckpt:/your/ckpt` to your data and checkpoint volume
docker run --device /dev/cambricon_ctl --network host --pid=host \
-v /sys/kernel/debug:/sys/kernel/debug -it --privileged \
--name $CONTAINER_NAME \
-v /your/data:/your/data \
-v /your/ckpt:/your/ckpt \
-e PYTORCH_TRAIN_DATASET=$PYTORCH_TRAIN_DATASET \
-v $PWD/../../../..:/home/pytorch_modelzoo \
-w /home/pytorch_modelzoo/built-in/cv/detection/PointPillar \
$IMAGE_NAME /bin/bash
else
docker start $CONTAINER_NAME
docker exec -ti $CONTAINER_NAME /bin/bash
fi