Skip to content

Commit 233d05d

Browse files
authored
update_gan scripts for benchmark (#500)
* update_gan scripts for benchmark * update_gan scripts for benchmark
1 parent 3c9dd7b commit 233d05d

File tree

4 files changed

+51
-44
lines changed

4 files changed

+51
-44
lines changed

benchmark/benchmark.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@ StyleGANv2:
22
dataset_web: https://paddlegan.bj.bcebos.com/datasets/ffhq.tar
33
config: configs/stylegan_v2_256_ffhq.yaml
44
fp_item: fp32
5-
bs_item: 3 8
5+
bs_item: 8
66
total_iters: 100
77
log_interval: 5
88

99
FOMM:
1010
dataset_web: https://paddlegan.bj.bcebos.com/datasets/fom_test_data.tar
1111
config: configs/firstorder_vox_256.yaml
1212
fp_item: fp32
13-
bs_item: 8 16
13+
bs_item: 16
1414
epochs: 1
1515
log_interval: 1
1616

1717
esrgan:
1818
dataset_web: https://paddlegan.bj.bcebos.com/datasets/DIV2KandSet14.tar
1919
config: configs/esrgan_psnr_x4_div2k.yaml
2020
fp_item: fp32
21-
bs_item: 32 64
21+
bs_item: 32
2222
total_iters: 300
2323
log_interval: 10
2424

2525
edvr:
2626
dataset: data/REDS
2727
config: configs/edvr_m_wo_tsa.yaml
2828
fp_item: fp32
29-
bs_item: 4 64
29+
bs_item: 4
3030
total_iters: 300
3131
log_interval: 10
3232

benchmark/prepare.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
#!usr/bin/env bash
3+
4+
export BENCHMARK_ROOT=/workspace
5+
run_env=$BENCHMARK_ROOT/run_env
6+
log_date=`date "+%Y.%m%d.%H%M%S"`
7+
frame=paddle2.1.3
8+
cuda_version=10.2
9+
save_log_dir=${BENCHMARK_ROOT}/logs/${frame}_${log_date}_${cuda_version}/
10+
11+
if [[ -d ${save_log_dir} ]]; then
12+
rm -rf ${save_log_dir}
13+
fi
14+
15+
# this for update the log_path coding mat
16+
export TRAIN_LOG_DIR=${save_log_dir}/train_log
17+
mkdir -p ${TRAIN_LOG_DIR}
18+
log_path=${TRAIN_LOG_DIR}
19+
20+
################################# 配置python, 如:
21+
rm -rf $run_env
22+
mkdir $run_env
23+
echo `which python3.7`
24+
ln -s $(which python3.7)m-config $run_env/python3-config
25+
ln -s $(which python3.7) $run_env/python
26+
ln -s $(which pip3.7) $run_env/pip
27+
28+
export PATH=$run_env:${PATH}
29+
cd $BENCHMARK_ROOT
30+
pip install -v -e .

benchmark/run_all.sh

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
1-
21
#!usr/bin/env bash
32

4-
export BENCHMARK_ROOT=/workspace
5-
run_env=$BENCHMARK_ROOT/run_env
6-
log_date=`date "+%Y.%m%d.%H%M%S"`
7-
frame=paddle2.1.3
8-
cuda_version=10.2
9-
save_log_dir=${BENCHMARK_ROOT}/logs/${frame}_${log_date}_${cuda_version}/
10-
11-
if [[ -d ${save_log_dir} ]]; then
12-
rm -rf ${save_log_dir}
13-
fi
14-
15-
# this for update the log_path coding mat
16-
export TRAIN_LOG_DIR=${save_log_dir}/train_log
17-
mkdir -p ${TRAIN_LOG_DIR}
18-
log_path=${TRAIN_LOG_DIR}
19-
20-
################################# 配置python, 如:
21-
rm -rf $run_env
22-
mkdir $run_env
23-
echo `which python3.7`
24-
ln -s $(which python3.7)m-config $run_env/python3-config
25-
ln -s $(which python3.7) $run_env/python
26-
ln -s $(which pip3.7) $run_env/pip
27-
28-
export PATH=$run_env:${PATH}
29-
cd $BENCHMARK_ROOT
30-
pip install -v -e .
31-
3+
export log_path=${LOG_PATH_INDEX_DIR:-$(pwd)}
324

335
function parse_yaml {
346
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
@@ -79,17 +51,17 @@ for model_mode in ${model_mode_list[@]}; do
7951
for fp_item in ${fp_item_list[@]}; do
8052
for bs_item in ${bs_list[@]}
8153
do
82-
echo "index is speed, 1gpus, begin, ${model_name}"
54+
echo "index is speed, 1gpus, begin, ${model_mode}"
8355
run_mode=sp
84-
CUDA_VISIBLE_DEVICES=0 benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile} # (5min)
56+
CUDA_VISIBLE_DEVICES=0 benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile} | tee ${log_path}/gan_dygraph_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_speed_1gpus 2>&1 # (5min)
8557
sleep 60
86-
echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_name}"
58+
echo "index is speed, 8gpus, run_mode is multi_process, begin, ${model_mode}"
8759
run_mode=mp
8860
basicvsr_name=basicvsr
8961
if [ ${model_mode} = ${basicvsr_name} ]; then
90-
CUDA_VISIBLE_DEVICES=0,1,2,3 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile}
62+
CUDA_VISIBLE_DEVICES=0,1,2,3 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile} | tee ${log_path}/gan_dygraph_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_speed_4gpus4p 2>&1
9163
else
92-
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile}
64+
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash benchmark/run_benchmark.sh ${run_mode} ${bs_item} ${fp_item} ${mode} ${max_iter} ${model_mode} ${config} ${log_interval} ${profile} | tee ${log_path}/gan_dygraph_${model_mode}_${run_mode}_bs${bs_item}_${fp_item}_speed_8gpus8p 2>&1
9365
fi
9466
sleep 60
9567
done

benchmark/run_benchmark.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ function _set_params(){
1414
run_log_path=${TRAIN_LOG_DIR:-$(pwd)} # TRAIN_LOG_DIR 后续QA设置该参数
1515
need_profile=${9:-"off"}
1616

17+
index=1
18+
base_batch_size=${batch_size}
19+
mission_name="图像生成"
20+
direction_id=0
21+
keyword="ips:"
22+
keyword_loss="G_idt_A_loss:"
23+
skip_steps=5
24+
ips_unit="images/s"
25+
1726
# 以下不用修改
1827
device=${CUDA_VISIBLE_DEVICES//,/ }
1928
arr=(${device})
@@ -23,9 +32,6 @@ function _set_params(){
2332
log_profile=${run_log_path}/${model_name}_model.profile
2433
}
2534

26-
function _analysis_log(){
27-
python benchmark/analysis_log.py ${model_name} ${log_file} ${res_log_file}
28-
}
2935

3036
function _train(){
3137
echo "Train on ${num_gpu_devices} GPUs"
@@ -65,9 +71,8 @@ function _train(){
6571
cp mylog/workerlog.0 ${log_file}
6672
fi
6773

68-
_analysis_log
69-
7074
}
7175

76+
source ${BENCHMARK_ROOT}/scripts/run_model.sh # 在该脚本中会对符合benchmark规范的log使用analysis.py 脚本进行性能数据解析;该脚本在连调时可从benchmark repo中下载https://github.com/PaddlePaddle/benchmark/blob/master/scripts/run_model.sh;如果不联调只想要产出训练log可以注掉本行,提交时需打开
7277
_set_params $@
73-
_train
78+
_run

0 commit comments

Comments
 (0)