forked from zczcwh/potter_page
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathddd_mmdet_train.sh
73 lines (62 loc) · 1.75 KB
/
ddd_mmdet_train.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
71
72
73
#!/usr/bin/env bash
if [ "$#" -lt 2 ]; then
echo "Usage: me.sh relative_config_filename remove_old_if_exist_0_or_1 [name_tag] [gpus] [nb_gpus] [port] [resume_dir]"
exit
fi
PYTHON=${PYTHON:-"python"}
if [ "$#" -gt 4 ]; then
GPUS=$4
NUM_GPUS=$5
else
GPUS=0,1,2,3,4,5,6,7
NUM_GPUS=8
fi
if [ "$#" -gt 5 ]; then
PORT=${PORT:-$6}
else
PORT=${PORT:-23700}
fi
if [ "$#" -gt 6 ]; then
RESUME=${RESUME:-$7}
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
CONFIG_FILE=$1
CONFIG_FILENAME=${CONFIG_FILE##*/}
CONFIG_BASE="${CONFIG_FILENAME%.*}"
if [ "$#" -gt 2 ]; then
WORK_DIR=$DIR/../work_dirs/ddd_detection/$CONFIG_BASE-$3
else
WORK_DIR=$DIR/../work_dirs/ddd_detection/$CONFIG_BASE
fi
if [ -d $WORK_DIR ]; then
echo "$WORK_DIR --- Already exists"
if [ $2 -gt 0 ]; then
while true; do
read -p "Are you sure to delete this result directory? " yn
case $yn in
[Yy]* ) rm -r $WORK_DIR; mkdir -p $WORK_DIR; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "Skip. Delete it first if retraining is needed"
exit
fi
else
mkdir -p $WORK_DIR
fi
if [ "$#" -gt 6 ]; then
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=$GPUS $PYTHON -m torch.distributed.launch \
--nproc_per_node=$NUM_GPUS --master_port=$PORT \
$DIR/../tools/mmdet3d_train.py $CONFIG_FILE \
--launcher pytorch \
--work-dir $WORK_DIR \
--resume-from $RESUME
else
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=$GPUS $PYTHON -m torch.distributed.launch \
--nproc_per_node=$NUM_GPUS --master_port=$PORT \
$DIR/../tools/mmdet3d_train.py $CONFIG_FILE \
--launcher pytorch \
--work-dir $WORK_DIR
fi