ResNet50_fp16.sh 1.2 KB
Newer Older
1 2 3 4 5 6 7 8
#!/bin/bash -ex

export FLAGS_conv_workspace_size_limit=4000 #MB
export FLAGS_cudnn_exhaustive_search=1
export FLAGS_cudnn_batchnorm_spatial_persistent=1

DATA_DIR="Your image dataset path, e.g. /work/datasets/ILSVRC2012/"
DATA_FORMAT="NHWC"
9
USE_AMP=true #whether to use amp
10
USE_PURE_FP16=true
11
USE_DALI=true
L
Leo Chen 已提交
12 13 14 15 16
USE_ADDTO=true

if ${USE_ADDTO} ;then
    export FLAGS_max_inplace_grad_add=8
fi
17 18 19 20 21 22 23 24 25 26

if ${USE_DALI}; then
    export FLAGS_fraction_of_gpu_memory_to_use=0.8
fi

python train.py \
       --model=ResNet50 \
       --data_dir=${DATA_DIR} \
       --batch_size=256 \
       --total_images=1281167 \
Z
Zhang Ting 已提交
27
       --image_shape 4 224 224 \
28 29 30 31
       --class_dim=1000 \
       --print_step=10 \
       --model_save_dir=output/ \
       --lr_strategy=piecewise_decay \
32 33
       --use_amp=${USE_AMP} \
       --use_pure_fp16=${USE_PURE_FP16} \
34 35 36 37 38
       --scale_loss=128.0 \
       --use_dynamic_loss_scaling=true \
       --data_format=${DATA_FORMAT} \
       --fuse_elewise_add_act_ops=true \
       --fuse_bn_act_ops=true \
Z
Zhang Ting 已提交
39
       --fuse_bn_add_act_ops=true \
L
Leo Chen 已提交
40
       --enable_addto=${USE_ADDTO} \
41 42 43 44 45 46
       --validate=true \
       --is_profiler=false \
       --profiler_path=profile/ \
       --reader_thread=10 \
       --reader_buf_size=4000 \
       --use_dali=${USE_DALI} \
47
       --lr=0.1
48