提交 18ec3818 编写于 作者: L LDOUBLEV

support std log for ocr

上级 fb430d25
...@@ -24,16 +24,19 @@ def parse_benchmark(filein, fileout): ...@@ -24,16 +24,19 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout: with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False) yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device): def gen_yml(device, gpu_id):
fin = open("config.yml", "r") fin = open("config.yml", "r")
config = yaml.load(fin) config = yaml.load(fin)
fin.close() fin.close()
config["dag"]["tracer"] = {"interval_s": 10} config["dag"]["tracer"] = {"interval_s": 10}
if device == "gpu": if device == "gpu":
config["op"]["det"]["local_service_conf"]["device_type"] = 1 config["op"]["det"]["local_service_conf"]["device_type"] = 1
config["op"]["det"]["local_service_conf"]["devices"] = "2" config["op"]["det"]["local_service_conf"]["devices"] = gpu_id
config["op"]["rec"]["local_service_conf"]["device_type"] = 1 config["op"]["rec"]["local_service_conf"]["device_type"] = 1
config["op"]["rec"]["local_service_conf"]["devices"] = "2" config["op"]["rec"]["local_service_conf"]["devices"] = gpu_id
else:
config["op"]["rec"]["local_service_conf"]["device_type"] = 0
config["op"]["det"]["local_service_conf"]["device_type"] = 0
with open("config2.yml", "w") as fout: with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False) yaml.dump(config, fout, default_flow_style=False)
...@@ -85,7 +88,11 @@ if __name__ == "__main__": ...@@ -85,7 +88,11 @@ if __name__ == "__main__":
mode = sys.argv[2] # brpc/ local predictor mode = sys.argv[2] # brpc/ local predictor
thread = int(sys.argv[3]) thread = int(sys.argv[3])
device = sys.argv[4] device = sys.argv[4]
gen_yml(device) if device == "gpu":
gpu_id = sys.argv[5]
gen_yml(device, gpu_id)
else:
gen_yml(device, "0")
elif sys.argv[1] == "run": elif sys.argv[1] == "run":
mode = sys.argv[2] # http/ rpc mode = sys.argv[2] # http/ rpc
thread = int(sys.argv[3]) thread = int(sys.argv[3])
......
export FLAGS_profile_pipeline=1 export FLAGS_profile_pipeline=1
alias python3="python3.7" alias python3="python3.7"
modelname="ocr" modelname="ocr"
use_gpu=0
gpu_id="0"
benchmark_config_filename="benchmark_config.yaml"
# HTTP # HTTP
ps -ef | grep web_service | awk '{print $2}' | xargs kill -9 ps -ef | grep web_service | awk '{print $2}' | xargs kill -9
sleep 3 sleep 3
python3 benchmark.py yaml local_predictor 1 gpu if [ $use_gpu -eq 1 ]; then
python3 benchmark.py yaml local_predictor 1 gpu $gpu_id
else
python3 benchmark.py yaml local_predictor 1 cpu
fi
rm -rf profile_log_$modelname rm -rf profile_log_$modelname
for thread_num in 1 8 16 for thread_num in 1
do do
for batch_size in 1 for batch_size in 1
do do
echo "----Bert thread num: $thread_num batch size: $batch_size mode:http ----" >>profile_log_$modelname echo "#----OCR thread num: $thread_num batch size: $batch_size mode:http use_gpu: $use_gpu----" >>profile_log_$modelname
rm -rf PipelineServingLogs rm -rf PipelineServingLogs
rm -rf cpu_utilization.py rm -rf cpu_utilization.py
python3 web_service.py >web.log 2>&1 & python3 web_service.py >web.log 2>&1 &
sleep 3 sleep 3
nvidia-smi --id=2 --query-compute-apps=used_memory --format=csv -lms 100 > gpu_use.log 2>&1 & nvidia-smi --id=${gpu_id} --query-compute-apps=used_memory --format=csv -lms 100 > gpu_use.log 2>&1 &
nvidia-smi --id=2 --query-gpu=utilization.gpu --format=csv -lms 100 > gpu_utilization.log 2>&1 & nvidia-smi --id=${gpu_id} --query-gpu=utilization.gpu --format=csv -lms 100 > gpu_utilization.log 2>&1 &
echo "import psutil\ncpu_utilization=psutil.cpu_percent(1,False)\nprint('CPU_UTILIZATION:', cpu_utilization)\n" > cpu_utilization.py echo "import psutil\ncpu_utilization=psutil.cpu_percent(1,False)\nprint('CPU_UTILIZATION:', cpu_utilization)\n" > cpu_utilization.py
python3 benchmark.py run http $thread_num $batch_size python3 benchmark.py run http $thread_num $batch_size
python3 cpu_utilization.py >>profile_log_$modelname python3 cpu_utilization.py >>profile_log_$modelname
python3 -m paddle_serving_server_gpu.profiler >>profile_log_$modelname
ps -ef | grep web_service | awk '{print $2}' | xargs kill -9 ps -ef | grep web_service | awk '{print $2}' | xargs kill -9
ps -ef | grep nvidia-smi | awk '{print $2}' | xargs kill -9
python3 benchmark.py dump benchmark.log benchmark.tmp python3 benchmark.py dump benchmark.log benchmark.tmp
mv benchmark.tmp benchmark.log mv benchmark.tmp benchmark.log
awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "MAX_GPU_MEMORY:", max}' gpu_use.log >> profile_log_$modelname awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "GPU_MEM:", max}' gpu_use.log >> profile_log_$modelname
awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "GPU_UTILIZATION:", max}' gpu_utilization.log >> profile_log_$modelname awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "GPU_UTIL:", max}' gpu_utilization.log >> profile_log_$modelname
cat benchmark.log >> profile_log_$modelname cat benchmark.log >> profile_log_$modelname
python3 -m paddle_serving_server_gpu.parse_profile --benchmark_cfg $benchmark_config_filename --benchmark_log profile_log_$modelname
#rm -rf gpu_use.log gpu_utilization.log #rm -rf gpu_use.log gpu_utilization.log
done done
done done
# RPC
ps -ef | grep web_service | awk '{print $2}' | xargs kill -9
sleep 3
python3 benchmark.py yaml local_predictor 1 gpu
for thread_num in 1 8 16
do
for batch_size in 1
do
echo "----Bert thread num: $thread_num batch size: $batch_size mode:rpc ----" >>profile_log_$modelname
rm -rf PipelineServingLogs
rm -rf cpu_utilization.py
python3 web_service.py >web.log 2>&1 &
sleep 3
nvidia-smi --id=2 --query-compute-apps=used_memory --format=csv -lms 100 > gpu_use.log 2>&1 &
nvidia-smi --id=2 --query-gpu=utilization.gpu --format=csv -lms 100 > gpu_utilization.log 2>&1 &
echo "import psutil\ncpu_utilization=psutil.cpu_percent(1,False)\nprint('CPU_UTILIZATION:', cpu_utilization)\n" > cpu_utilization.py
python3 benchmark.py run rpc $thread_num $batch_size
python3 cpu_utilization.py >>profile_log_$modelname
ps -ef | grep web_service | awk '{print $2}' | xargs kill -9
python3 benchmark.py dump benchmark.log benchmark.tmp
mv benchmark.tmp benchmark.log
awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "MAX_GPU_MEMORY:", max}' gpu_use.log >> profile_log_$modelname
awk 'BEGIN {max = 0} {if(NR>1){if ($modelname > max) max=$modelname}} END {print "GPU_UTILIZATION:", max}' gpu_utilization.log >> profile_log_$modelname
#rm -rf gpu_use.log gpu_utilization.log
cat benchmark.log >> profile_log_$modelname
done
done
cuda_version: "10.1"
cudnn_version: "7.6"
trt_version: "6.0"
python_version: "3.7"
gcc_version: "8.2"
paddle_version: "2.0.1"
cpu: "Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz X12"
gpu: "T4"
xpu: "None"
api: ""
owner: "yingxiaoting"
model_name: "ocr"
model_type: "static"
model_source: "PaddleOCR"
model_url: ""
batch_size: 1
num_of_samples: 1000
input_shape: "3,32,X"
runtime_device: "cpu"
ir_optim: true
enable_memory_optim: true
enable_tensorrt: false
precision: "fp32"
enable_mkldnn: false
cpu_math_library_num_threads: ""
sed -e "s/imagenet/${modelname}/g" benchmark_config.yaml.template >benchmark_config.yaml
sh benchmark.sh
mv std_benchmark.log std_benchmark.log.cpu
sed -e "s/use_gpu=0/use_gpu=1/g" benchmark.sh>benchmark_gpu.sh
sed -e "s/imagenet/${modelname}/g" -e "s/runtime_device: \"cpu\"/runtime_device: \"gpu\"/g" benchmark_config.yaml.template >benchmark_config.yaml
sh benchmark_gpu.sh
mv std_benchmark.log std_benchmark.log.gpu
cp std_benchmark.log.cpu /paddle/Cls/tools/serving_log/${modelname}.log.cpu
cp std_benchmark.log.gpu /paddle/Cls/tools/serving_log/${modelname}.log.gpu
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册