benchmark.sh 1.8 KB
Newer Older
M
MRXLT 已提交
1
rm profile_log
M
MRXLT 已提交
2 3 4
export CUDA_VISIBLE_DEVICES=0,1,2,3
export FLAGS_profile_server=1
export FLAGS_profile_client=1
M
MRXLT 已提交
5
export FLAGS_serving_latency=1
M
MRXLT 已提交
6
python3 -m paddle_serving_server_gpu.serve --model $1 --port 9292 --thread 4 --gpu_ids 0,1,2,3 --mem_optim --ir_optim 2> elog > stdlog &
G
gentelyang 已提交
7
hostname=`echo $(hostname)|awk -F '.baidu.com' '{print $1}'`
M
MRXLT 已提交
8
sleep 5
G
gentelyang 已提交
9
gpu_id=0
M
MRXLT 已提交
10 11

#warm up
M
MRXLT 已提交
12
python3 benchmark.py --thread 8 --batch_size 1 --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1
M
MRXLT 已提交
13

M
MRXLT 已提交
14
for thread_num in 4 8 16
M
MRXLT 已提交
15
do
M
MRXLT 已提交
16 17
for batch_size in 1 4 16 64 256
do
G
gentelyang 已提交
18 19 20
    job_bt=`date '+%Y%m%d%H%M%S'`
    nvidia-smi --id=$gpu_id --query-compute-apps=used_memory --format=csv -lms 100 > gpu_use.log 2>&1 &
    gpu_memory_pid=$!
M
MRXLT 已提交
21
    python3 benchmark.py --thread $thread_num --batch_size $batch_size --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1
G
gentelyang 已提交
22 23 24 25
    kill ${gpu_memory_pid}
    echo "model_name:" $1
    echo "thread_num:" $thread_num
    echo "batch_size:" $batch_size
M
MRXLT 已提交
26
    echo "=================Done===================="
G
gentelyang 已提交
27 28 29 30 31 32 33 34 35
    echo "model_name:$1" >> profile_log_$1
    echo "batch_size:$batch_size" >> profile_log_$1
    job_et=`date '+%Y%m%d%H%M%S'`
    awk 'BEGIN {max = 0} {if(NR>1){if ($1 > max) max=$1}} END {print "MAX_GPU_MEMORY_USE:", max}' gpu_use.log >> profile_log_$1
    monquery -n ${hostname} -i GPU_AVERAGE_UTILIZATION -s $job_bt -e $job_et -d 10 > gpu_log_file_${job_bt}
    monquery -n ${hostname} -i CPU_USER -s $job_bt -e $job_et  -d 10 > cpu_log_file_${job_bt}
    cpu_num=$(cat /proc/cpuinfo | grep processor | wc -l)
    gpu_num=$(nvidia-smi -L|wc -l)
    python ../util/show_profile.py profile $thread_num >> profile_log_$1
M
MRXLT 已提交
36 37
    tail -n 8 profile >> profile_log_$1
    echo "" >> profile_log_$1
M
MRXLT 已提交
38
done
M
MRXLT 已提交
39
done
M
MRXLT 已提交
40 41

ps -ef|grep 'serving'|grep -v grep|cut -c 9-15 | xargs kill -9