benchmark.sh 1.6 KB
Newer Older
G
fix  
gentelyang 已提交
1
rm profile_log*
G
gentelyang 已提交
2 3 4
export FLAGS_profile_server=1
export FLAGS_profile_client=1
export FLAGS_serving_latency=1
G
fix  
gentelyang 已提交
5
$PYTHONROOT/bin/python3 -m paddle_serving_server.serve --model $1 --port 9292 --thread 4 --mem_optim --ir_optim  2> elog > stdlog &
G
gentelyang 已提交
6
hostname=`echo $(hostname)|awk -F '.baidu.com' '{print $1}'`
G
fix  
gentelyang 已提交
7 8 9 10 11 12
#save cpu and gpu utilization log
if [ -d utilization ];then
    rm -rf utilization
else
    mkdir utilization
fi
G
gentelyang 已提交
13 14
sleep 5

M
MRXLT 已提交
15

G
fix  
gentelyang 已提交
16 17 18 19 20
#warm up
$PYTHONROOT/bin/python3 benchmark.py --thread 4 --batch_size 1 --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1
echo -e "import psutil\ncpu_utilization=psutil.cpu_percent(1,False)\nprint('CPU_UTILIZATION:', cpu_utilization)\n" > cpu_utilization.py

for thread_num in 1 4 8 16
M
MRXLT 已提交
21
do
G
fix  
gentelyang 已提交
22
for batch_size in 1 4 16 64
M
MRXLT 已提交
23
do
G
gentelyang 已提交
24
    job_bt=`date '+%Y%m%d%H%M%S'`
G
fix  
gentelyang 已提交
25
    $PYTHONROOT/bin/python3 benchmark.py --thread $thread_num --batch_size $batch_size --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1
G
gentelyang 已提交
26 27 28 29 30 31 32
    echo "model_name:" $1
    echo "thread_num:" $thread_num
    echo "batch_size:" $batch_size
    echo "=================Done===================="
    echo "model_name:$1" >> profile_log_$1
    echo "batch_size:$batch_size" >> profile_log_$1
    job_et=`date '+%Y%m%d%H%M%S'`
G
fix  
gentelyang 已提交
33 34
    $PYTHONROOT/bin/python3 ../util/show_profile.py profile $thread_num >> profile_log_$1
    $PYTHONROOT/bin/python3 cpu_utilization.py >> profile_log_$1
G
gentelyang 已提交
35 36
    tail -n 8 profile >> profile_log_$1
    echo "" >> profile_log_$1
M
MRXLT 已提交
37
done
M
MRXLT 已提交
38
done
G
gentelyang 已提交
39

G
fix  
gentelyang 已提交
40 41 42
#Divided log
awk 'BEGIN{RS="\n\n"}{i++}{print > "imdb_log_"i}' profile_log_$1
mkdir $1_log && mv imdb_log_* $1_log
G
gentelyang 已提交
43
ps -ef|grep 'serving'|grep -v grep|cut -c 9-15 | xargs kill -9