train.sh 695 字节
Newer Older
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13 14

if [ $# != 2 ];then
    echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name"
    exit -1
fi

ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}')
echo "using $ngpu gpus..."

config_path=$1
ckpt_name=$2

device=gpu
15
if [ ${ngpu} == 0 ];then
16 17 18 19 20 21
    device=cpu
fi
echo "using ${device}..."

mkdir -p exp

H
Hui Zhang 已提交
22 23
seed=10086
if [ ${seed} != 0]; then
H
huangyuxin 已提交
24 25 26
    export FLAGS_cudnn_deterministic=True
fi

27 28 29 30
python3 -u ${BIN_DIR}/train.py \
--device ${device} \
--nproc ${ngpu} \
--config ${config_path} \
H
huangyuxin 已提交
31 32 33
--output exp/${ckpt_name} \
--seed ${seed}

H
Hui Zhang 已提交
34
if [ ${seed} != 0 ]; then
H
huangyuxin 已提交
35 36
    unset FLAGS_cudnn_deterministic
fi
37 38 39 40 41 42 43

if [ $? -ne 0 ]; then
    echo "Failed in training!"
    exit 1
fi

exit 0