未验证 提交 32132fa9 编写于 作者: L lzzyzlbb 提交者: GitHub

Fix benchmark (#451)

* fix benchmark

* add fomm and stylegan benchmark
上级 5fd051d3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# encoding=utf-8 vi:ts=4:sw=4:expandtab:ft=python
import re
import sys
import json
def analyze(model_name, log_file, res_log_file):
time_pat = re.compile(r"ips: (.*) images/s")
logs = open(log_file).readlines()
logs = ";".join(logs)
time_res = time_pat.findall(logs)
fail_flag = 0
run_mode = ""
gpu_num = 0
ips = 0
if time_res == []:
fail_flag = 1
else:
gpu_num = log_file.split('_')[-1]
run_mode = "sp" if gpu_num == 1 else "mp"
skip_num = 4
total_time = 0
for i in range(skip_num, len(time_res)):
total_time += float(time_res[i])
ips = total_time / (len(time_res) - skip_num)
info = {"log_file": log_file, "model_name": model_name, "mission_name": "图像生成",
"direction_id": 0, "run_mode": run_mode, "index": 1, "gpu_num": gpu_num,
"FINAL_RESULT": ips, "JOB_FAIL_FLAG": fail_flag, "UNIT": "images/s"}
json_info = json.dumps(info)
with open(res_log_file, "w") as of:
of.write(json_info)
if __name__ == "__main__":
if len(sys.argv) != 4:
print("Usage:" + sys.argv[0] + " model_name path/to/log/file path/to/res/log/file")
sys.exit()
model_name = sys.argv[1]
log_file = sys.argv[2]
res_log_file = sys.argv[3]
analyze(model_name, log_file, res_log_file)
......@@ -18,7 +18,13 @@ function _set_params(){
arr=(${device})
num_gpu_devices=${#arr[*]}
log_file=${run_log_path}/${model_name}_${run_mode}_bs${batch_size}_${fp_item}_${num_gpu_devices}
res_log_file=${run_log_path}/${model_name}_${run_mode}_bs${batch_size}_${fp_item}_${num_gpu_devices}_speed
}
function _analysis_log(){
python benchmark/analysis_log.py ${model_name} ${log_file} ${res_log_file}
}
function _train(){
echo "Train on ${num_gpu_devices} GPUs"
echo "current CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES, gpus=$num_gpu_devices, batch_size=$batch_size"
......@@ -49,6 +55,9 @@ function _train(){
rm ${log_file}
cp mylog/workerlog.0 ${log_file}
fi
_analysis_log
}
_set_params $@
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册