ipipe_py3.sh 38.1 KB
Newer Older
L
liyang109 已提交
1 2 3 4 5
#!/bin/bash
echo "################################################################"
echo "#                                                              #"
echo "#                                                              #"
echo "#                                                              #"
Z
zhangyulong04 已提交
6
echo "#          Paddle Serving  begin run  with python$1!           #"
L
liyang109 已提交
7 8 9 10 11 12 13 14
echo "#                                                              #"
echo "#                                                              #"
echo "#                                                              #"
echo "################################################################"
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export CUDA_INCLUDE_DIRS=/usr/local/cuda-10.2/include
export PYTHONROOT=/usr/local
Z
Zhang Yulong 已提交
15 16 17 18 19 20
export PYTHONIOENCODING=utf-8

build_path=/workspace/Serving/
error_words="Fail|DENIED|UNKNOWN|None"
log_dir=${build_path}logs/
data=/root/.cache/serving_data/
Z
zhangyulong04 已提交
21
OPENCV_DIR=${data}/opencv-3.4.7/opencv3
Z
Zhang Yulong 已提交
22 23 24 25 26 27 28 29 30 31
dir=`pwd`
RED_COLOR='\E[1;31m'
GREEN_COLOR='\E[1;32m'
YELOW_COLOR='\E[1;33m'
RES='\E[0m'
cuda_version=`cat /usr/local/cuda/version.txt`

if [ $? -ne 0 ]; then
    cuda_version=11
fi
L
liyang109 已提交
32 33 34 35 36 37 38

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
go get -u github.com/golang/protobuf/protoc-gen-go@v1.4.3
go get -u google.golang.org/grpc@v1.33.0
Z
ZhangYulongg 已提交
39
go env -w GO111MODULE=auto
L
liyang109 已提交
40

Z
Zhang Yulong 已提交
41
build_whl_list=(build_cpu_server build_gpu_server build_client build_app)
Z
Zhang Yulong 已提交
42
rpc_model_list=(grpc_fit_a_line grpc_yolov4 pipeline_imagenet bert_rpc_gpu bert_rpc_cpu ResNet50_rpc \
Z
add  
ZhangYulongg 已提交
43
lac_rpc_asyn cnn_rpc_asyn bow_rpc lstm_rpc fit_a_line_rpc deeplabv3_rpc mobilenet_rpc unet_rpc resnetv2_rpc \
Z
Zhang Yulong 已提交
44
criteo_ctr_rpc_cpu criteo_ctr_rpc_gpu ocr_rpc yolov4_rpc_gpu faster_rcnn_hrnetv2p_w18_1x_encrypt \
Z
add  
ZhangYulongg 已提交
45
faster_rcnn_model_rpc low_precision_resnet50_int8 ocr_c++_service ocr_c++_service_asyn)
Z
ZhangYulongg 已提交
46
http_model_list=(fit_a_line_http lac_http imdb_http_proto imdb_http_json imdb_grpc ResNet50_http bert_http \
Z
Zhang Yulong 已提交
47
pipeline_ocr_cpu_http)
L
liyang109 已提交
48

Z
Zhang Yulong 已提交
49 50 51
function setproxy() {
    export http_proxy=${proxy}
    export https_proxy=${proxy}
L
liyang109 已提交
52 53
}

Z
Zhang Yulong 已提交
54 55 56
function unsetproxy() {
    unset http_proxy
    unset https_proxy
L
liyang109 已提交
57 58
}

Z
Zhang Yulong 已提交
59 60 61 62
function kill_server_process() {
    kill `ps -ef | grep serving | awk '{print $2}'` > /dev/null 2>&1
    kill `ps -ef | grep python | awk '{print $2}'` > /dev/null 2>&1
    echo -e "${GREEN_COLOR}process killed...${RES}"
L
liyang109 已提交
63 64
}

Z
zhangyulong04 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
function set_env() {
    if [ $1 == 36 ]; then
        export PYTHONROOT=/usr/local/
        export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.6m
        export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.6m.so
        export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.6
        py_version="python3.6"
    elif [ $1 == 37 ]; then
        export PYTHONROOT=/usr/local/
        export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.7m
        export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.7m.so
        export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.7
        py_version="python3.7"
    elif [ $1 == 38 ]; then
        export PYTHONROOT=/usr/local/
        export PYTHON_INCLUDE_DIR=$PYTHONROOT/include/python3.8
        export PYTHON_LIBRARIES=$PYTHONROOT/lib/libpython3.8.so
        export PYTHON_EXECUTABLE=$PYTHONROOT/bin/python3.8
        py_version="python3.8"
    else
        echo -e "${RED_COLOR}Error py version$1${RES}"
        exit
    fi
    export CUDA_PATH='/usr/local/cuda'
    export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
    export CUDA_CUDART_LIBRARY="/usr/local/cuda/lib64/"
    if [ $2 == 101 ]; then
        export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/"
    elif [ $2 == 102 ]; then
        export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT-7.1.3.4/targets/x86_64-linux-gnu/"
    elif [ $2 == 110 ]; then
        export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT-7.1.3.4/targets/x86_64-linux-gnu/"
    elif [ $2 == "cpu" ]; then
        export TENSORRT_LIBRARY_PATH="/usr/local/TensorRT6-cuda9.0-cudnn7/targets/x86_64-linux-gnu"
    else
        echo -e "${RED_COLOR}Error cuda version$1${RES}"
        exit
    fi
}

L
liyang109 已提交
105 106 107
function check() {
    cd ${build_path}
    if [ ! -f paddle_serving_app* ]; then
Z
Zhang Yulong 已提交
108 109
        echo "paddle_serving_app is compiled failed, please check your pull request"
        exit 1
Z
Zhang Yulong 已提交
110 111 112
    elif [ ! -f paddle_serving_server-* ]; then
        echo "paddle_serving_server-cpu is compiled failed, please check your pull request"
        exit 1
L
liyang109 已提交
113
    elif [ ! -f paddle_serving_server_* ]; then
Z
Zhang Yulong 已提交
114 115
        echo "paddle_serving_server_gpu is compiled failed, please check your pull request"
        exit 1
L
liyang109 已提交
116
    elif [ ! -f paddle_serving_client* ]; then
Z
Zhang Yulong 已提交
117 118
        echo "paddle_serving_server_client is compiled failed, please check your pull request"
        exit 1
L
liyang109 已提交
119
    else
Z
Zhang Yulong 已提交
120
        echo "paddle serving build passed"
L
liyang109 已提交
121 122 123
    fi
}

Z
ZhangYulongg 已提交
124 125 126 127 128 129 130 131 132 133 134
function check_gpu_memory() {
    gpu_memory=`nvidia-smi --id=$1 --format=csv,noheader --query-gpu=memory.used | awk '{print $1}'`
    echo -e "${GREEN_COLOR}-------id-$1 gpu_memory_used: ${gpu_memory}${RES}"
    if [ ${gpu_memory} -le 100 ]; then
        echo "-------GPU-$1 is not used"
        status="GPU-$1 is not used"
    else
        echo "-------GPU_memory used is expected"
    fi
}

L
liyang109 已提交
135
function check_result() {
Z
Zhang Yulong 已提交
136 137 138 139
    if [ $? == 0 ]; then
        echo -e "${GREEN_COLOR}$1 execute normally${RES}"
        if [ $1 == "server" ]; then
            sleep $2
Z
ZhangYulongg 已提交
140
            cat ${dir}server_log.txt | tee -a ${log_dir}server_total.txt
Z
Zhang Yulong 已提交
141 142
        fi
        if [ $1 == "client" ]; then
Z
ZhangYulongg 已提交
143
            cat ${dir}client_log.txt | tee -a ${log_dir}client_total.txt
Z
Zhang Yulong 已提交
144 145
            grep -E "${error_words}" ${dir}client_log.txt > /dev/null
            if [ $? == 0 ]; then
Z
ZhangYulongg 已提交
146 147 148 149 150
                if [ "${status}" != "" ]; then
                    status="${status}|Failed"
                else
                    status="Failed"
                fi
Z
Zhang Yulong 已提交
151
                echo -e "${RED_COLOR}$1 error command${RES}\n" | tee -a ${log_dir}server_total.txt ${log_dir}client_total.txt
Z
ZhangYulongg 已提交
152
                echo "--------------server log:--------------"
Z
ZhangYulongg 已提交
153
                cat ${dir}server_log.txt
Z
ZhangYulongg 已提交
154 155 156
                echo "--------------client log:--------------"
                cat ${dir}client_log.txt
                echo "--------------pipeline.log:----------------"
Z
zhangyulong04 已提交
157
                cat PipelineServingLogs/pipeline.log
Z
ZhangYulongg 已提交
158
                echo "-------------------------------------------\n"
Z
Zhang Yulong 已提交
159 160
                error_log $2
            else
Z
ZhangYulongg 已提交
161 162 163
                if [ "${status}" != "" ]; then
                    error_log $2
                fi
Z
Zhang Yulong 已提交
164 165 166
                echo -e "${GREEN_COLOR}$2${RES}\n" | tee -a ${log_dir}server_total.txt ${log_dir}client_total.txt
            fi
        fi
L
liyang109 已提交
167
    else
Z
Zhang Yulong 已提交
168
        echo -e "${RED_COLOR}$1 error command${RES}\n" | tee -a ${log_dir}server_total.txt ${log_dir}client_total.txt
Z
ZhangYulongg 已提交
169
        echo "--------------server log:--------------"
Z
ZhangYulongg 已提交
170
        cat ${dir}server_log.txt
Z
ZhangYulongg 已提交
171 172 173 174 175
        echo "--------------client log:--------------"
        cat ${dir}client_log.txt
        echo "--------------pipeline.log:----------------"
        cat PipelineServingLogs/pipeline.log
        echo "-------------------------------------------\n"
Z
ZhangYulongg 已提交
176 177 178 179 180
        if [ "${status}" != "" ]; then
            status="${status}|Failed"
        else
            status="Failed"
        fi
Z
Zhang Yulong 已提交
181
        error_log $2
L
liyang109 已提交
182
    fi
Z
ZhangYulongg 已提交
183
    status=""
L
liyang109 已提交
184 185
}

Z
Zhang Yulong 已提交
186 187 188 189 190 191 192 193 194 195 196 197 198 199
function error_log() {
    arg=${1//\//_}
    echo "-----------------------------" | tee -a ${log_dir}error_models.txt
    arg=${arg%% *}
    arr=(${arg//_/ })
    if [ ${arr[@]: -1} == 1 -o ${arr[@]: -1} == 2 ]; then
        model=${arr[*]:0:${#arr[*]}-3}
        deployment=${arr[*]: -3}
    else
        model=${arr[*]:0:${#arr[*]}-2}
        deployment=${arr[*]: -2}
    fi
    echo "model: ${model// /_}" | tee -a ${log_dir}error_models.txt
    echo "deployment: ${deployment// /_}" | tee -a ${log_dir}error_models.txt
Z
zhangyulong04 已提交
200
    echo "py_version: ${py_version}" | tee -a ${log_dir}error_models.txt
Z
Zhang Yulong 已提交
201
    echo "cuda_version: ${cuda_version}" | tee -a ${log_dir}error_models.txt
Z
ZhangYulongg 已提交
202
    echo "status: ${status}" | tee -a ${log_dir}error_models.txt
Z
Zhang Yulong 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215
    echo -e "-----------------------------\n\n" | tee -a ${log_dir}error_models.txt
    prefix=${arg//\//_}
    for file in ${dir}*
    do
        cp ${file} ${log_dir}error/${prefix}_${file##*/}
    done
}

function check_dir() {
    if [ ! -d "$1" ]
    then
        mkdir -p $1
    fi
L
liyang109 已提交
216 217
}

Z
Zhang Yulong 已提交
218 219 220 221 222 223 224 225
function link_data() {
    for file in $1*
    do
        if [ ! -h ${file##*/} ]
        then
            ln -s ${file} ./${file##*/}
        fi
    done
L
liyang109 已提交
226 227
}

Z
Zhang Yulong 已提交
228 229 230
function before_hook() {
    setproxy
    cd ${build_path}/python
Z
ZhangYulongg 已提交
231
    ${py_version} -m pip install --upgrade pip==21.1.3
Z
zhangyulong04 已提交
232
    ${py_version} -m pip install requests
Z
zhangyulong04 已提交
233
    ${py_version} -m pip install -r requirements.txt
Z
zhangyulong04 已提交
234
    ${py_version} -m pip install numpy==1.16.4
Z
zhangyulong04 已提交
235
    ${py_version} -m pip install paddlehub
Z
Zhang Yulong 已提交
236
    echo "before hook configuration is successful.... "
L
liyang109 已提交
237 238
}

Z
Zhang Yulong 已提交
239 240
function run_env() {
    setproxy
Z
zhangyulong04 已提交
241 242 243
    ${py_version} -m pip install nltk==3.4 -i https://mirror.baidu.com/pypi/simple
    ${py_version} -m pip install setuptools==41.0.0 -i https://mirror.baidu.com/pypi/simple
    ${py_version} -m pip install paddlehub -i https://mirror.baidu.com/pypi/simple
Z
zhangyulong04 已提交
244 245 246 247 248 249 250
    if [ ${py_version} == "python3.6" ]; then
        ${py_version} -m pip install paddlepaddle-gpu==2.1.0
    elif [ ${py_version} == "python3.8" ]; then
        cd ${build_path}
        wget https://paddle-wheel.bj.bcebos.com/with-trt/2.1.0-gpu-cuda11.0-cudnn8-mkl-gcc8.2/paddlepaddle_gpu-2.1.0.post110-cp38-cp38-linux_x86_64.whl
        ${py_version} -m pip install paddlepaddle_gpu-2.1.0.post110-cp38-cp38-linux_x86_64.whl
    fi
Z
Zhang Yulong 已提交
251 252 253 254 255 256 257 258 259
    echo "run env configuration is successful.... "
}

function run_gpu_env() {
    cd ${build_path}
    export LD_LIBRARY_PATH=/usr/local/lib64/python3.6/site-packages/paddle/libs/:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=/workspace/Serving/build_gpu/third_party/install/Paddle/lib/:/workspace/Serving/build_gpu/third_party/Paddle/src/extern_paddle/third_party/install/mklml/lib/:/workspace/Serving/build_gpu/third_party/Paddle/src/extern_paddle/third_party/install/mkldnn/lib/:$LD_LIBRARY_PATH
    export SERVING_BIN=${build_path}/build_gpu/core/general-server/serving
    echo "run gpu env configuration is successful.... "
L
liyang109 已提交
260 261 262 263 264 265 266 267 268 269 270 271 272
}

function build_gpu_server() {
    setproxy
    cd ${build_path}
    git submodule update --init --recursive
    if [ -d build_gpu ];then
        rm -rf build_gpu
    fi
    if [ -d build ];then
        rm -rf build
    fi
    mkdir build && cd build
Z
zhangyulong04 已提交
273 274 275 276 277 278 279
    cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
        -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
        -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
        -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_PATH} \
        -DCUDNN_LIBRARY=${CUDNN_LIBRARY} \
        -DCUDA_CUDART_LIBRARY=${CUDA_CUDART_LIBRARY} \
        -DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
Z
zhangyulong04 已提交
280 281
        -DOPENCV_DIR=${OPENCV_DIR} \
        -DWITH_OPENCV=ON \
Z
zhangyulong04 已提交
282 283
        -DSERVER=ON \
        -DWITH_GPU=ON ..
Z
Zhang Yulong 已提交
284 285 286
    make -j32
    make -j32
    make install -j32
Z
zhangyulong04 已提交
287 288
    ${py_version} -m pip uninstall paddle-serving-server-gpu -y
    ${py_version} -m pip install ${build_path}/build/python/dist/*
L
liyang109 已提交
289 290 291 292
    cp  ${build_path}/build/python/dist/* ../
    cp -r ${build_path}/build/ ${build_path}/build_gpu
}

Z
Zhang Yulong 已提交
293 294 295 296 297 298 299 300 301 302
function build_cpu_server(){
    setproxy
    cd ${build_path}
    if [ -d build_cpu ];then
        rm -rf build_cpu
    fi
    if [ -d build ];then
        rm -rf build
    fi
    mkdir build && cd build
Z
zhangyulong04 已提交
303 304 305
    cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR/ \
        -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
        -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
Z
zhangyulong04 已提交
306 307
        -DOPENCV_DIR=${OPENCV_DIR} \
        -DWITH_OPENCV=ON \
Z
zhangyulong04 已提交
308
        -DSERVER=ON ..
Z
Zhang Yulong 已提交
309 310 311 312
    make -j32
    make -j32
    make install -j32
    cp ${build_path}/build/python/dist/* ../
Z
zhangyulong04 已提交
313 314
    ${py_version} -m pip uninstall paddle-serving-server -y
    ${py_version} -m pip install ${build_path}/build/python/dist/*
Z
Zhang Yulong 已提交
315 316 317
    cp -r ${build_path}/build/ ${build_path}/build_cpu
}

L
liyang109 已提交
318
function build_client() {
Z
Zhang Yulong 已提交
319 320 321 322 323 324
    setproxy
    cd  ${build_path}
    if [ -d build ];then
        rm -rf build
    fi
    mkdir build && cd build
Z
zhangyulong04 已提交
325 326 327 328
    cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
        -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
        -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
        -DCLIENT=ON ..
Z
Zhang Yulong 已提交
329 330 331
    make -j32
    make -j32
    cp ${build_path}/build/python/dist/* ../
Z
zhangyulong04 已提交
332 333
    ${py_version} -m pip uninstall paddle-serving-client -y
    ${py_version} -m pip install ${build_path}/build/python/dist/*
L
liyang109 已提交
334 335 336
}

function build_app() {
Z
Zhang Yulong 已提交
337
    setproxy
Z
zhangyulong04 已提交
338 339
    ${py_version} -m pip install paddlehub ujson Pillow
    ${py_version} -m pip install paddlepaddle==2.0.2
Z
Zhang Yulong 已提交
340 341 342 343 344
    cd ${build_path}
    if [ -d build ];then
        rm -rf build
    fi
    mkdir build && cd build
Z
zhangyulong04 已提交
345 346 347 348
    cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
        -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
        -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
        -DAPP=ON ..
Z
Zhang Yulong 已提交
349 350
    make
    cp ${build_path}/build/python/dist/* ../
Z
zhangyulong04 已提交
351 352
    ${py_version} -m pip uninstall paddle-serving-app -y
    ${py_version} -m pip install ${build_path}/build/python/dist/*
Z
Zhang Yulong 已提交
353 354
}

Z
Zhang Yulong 已提交
355 356 357 358 359 360
function low_precision_resnet50_int8 () {
    dir=${log_dir}rpc_model/low_precision/resnet50/
    cd ${build_path}/python/examples/low_precision/resnet50/
    check_dir ${dir}
    wget https://paddle-inference-dist.bj.bcebos.com/inference_demo/python/resnet50/ResNet50_quant.tar.gz
    tar zxvf ResNet50_quant.tar.gz
Z
zhangyulong04 已提交
361
    ${py_version} -m paddle_serving_client.convert --dirname ResNet50_quant
Z
Zhang Yulong 已提交
362
    echo -e "${GREEN_COLOR}low_precision_resnet50_int8_GPU_RPC server started${RES}" | tee -a ${log_dir}server_total.txt
Z
zhangyulong04 已提交
363
    ${py_version} -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_ids 0 --use_trt --precision int8 > ${dir}server_log.txt 2>&1 &
Z
ZhangYulongg 已提交
364
    check_result server 15
Z
Zhang Yulong 已提交
365
    echo -e "${GREEN_COLOR}low_precision_resnet50_int8_GPU_RPC client started${RES}" | tee -a ${log_dir}client_total.txt
Z
zhangyulong04 已提交
366
    ${py_version} resnet50_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
367 368 369 370
    check_result client "low_precision_resnet50_int8_GPU_RPC server test completed"
    kill_server_process
}

Z
Zhang Yulong 已提交
371 372 373 374 375 376
function faster_rcnn_hrnetv2p_w18_1x_encrypt() {
    dir=${log_dir}rpc_model/faster_rcnn_hrnetv2p_w18_1x/
    cd ${build_path}/python/examples/detection/faster_rcnn_hrnetv2p_w18_1x
    check_dir ${dir}
    data_dir=${data}detection/faster_rcnn_hrnetv2p_w18_1x/
    link_data ${data_dir}
Z
zhangyulong04 已提交
377
    ${py_version} encrypt.py
Z
Zhang Yulong 已提交
378 379
    unsetproxy
    echo -e "${GREEN_COLOR}faster_rcnn_hrnetv2p_w18_1x_ENCRYPTION_GPU_RPC server started${RES}" | tee -a ${log_dir}server_total.txt
Z
ZhangYulongg 已提交
380
    ${py_version} -m paddle_serving_server.serve --model encrypt_server/ --port 9494 --gpu_ids 0 --use_encryption_model > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
381 382
    check_result server 3
    echo -e "${GREEN_COLOR}faster_rcnn_hrnetv2p_w18_1x_ENCRYPTION_GPU_RPC client started${RES}" | tee -a ${log_dir}client_total.txt
Z
zhangyulong04 已提交
383
    ${py_version} test_encryption.py 000000570688.jpg > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
    check_result client "faster_rcnn_hrnetv2p_w18_1x_ENCRYPTION_GPU_RPC server test completed"
    kill_server_process
}

function pipeline_ocr_cpu_http() {
    dir=${log_dir}rpc_model/pipeline_ocr_cpu_http/
    check_dir ${dir}
    cd ${build_path}/python/examples/pipeline/ocr
    data_dir=${data}ocr/
    link_data ${data_dir}
    unsetproxy
    echo -e "${GREEN_COLOR}pipeline_ocr_CPU_HTTP server started${RES}" | tee -a ${log_dir}server_total.txt
    $py_version web_service.py > ${dir}server_log.txt 2>&1 &
    check_result server 5
    echo -e "${GREEN_COLOR}pipeline_ocr_CPU_HTTP client started${RES}" | tee -a ${log_dir}client_total.txt
    timeout 15s $py_version pipeline_http_client.py > ${dir}client_log.txt 2>&1
    check_result client "pipeline_ocr_CPU_HTTP server test completed"
    kill_server_process
}

function bert_rpc_gpu() {
    dir=${log_dir}rpc_model/bert_rpc_gpu/
    check_dir ${dir}
    run_gpu_env
    unsetproxy
    cd ${build_path}/python/examples/bert
    data_dir=${data}bert/
    link_data ${data_dir}
    sh get_data.sh >/dev/null 2>&1
    sed -i 's/9292/8860/g' bert_client.py
    sed -i '$aprint(result)' bert_client.py
    ls -hlst
Z
zhangyulong04 已提交
416
    ${py_version} -m paddle_serving_server.serve --model bert_seq128_model/ --port 8860 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
417
    check_result server 15
Z
ZhangYulongg 已提交
418
    check_gpu_memory 0
Z
Zhang Yulong 已提交
419
    nvidia-smi
Z
zhangyulong04 已提交
420
    head data-c.txt | ${py_version} bert_client.py --model bert_seq128_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
421 422 423 424 425 426 427 428 429 430 431 432 433
    check_result client "bert_GPU_RPC server test completed"
    nvidia-smi
    kill_server_process
}

function bert_rpc_cpu() {
    dir=${log_dir}rpc_model/bert_rpc_cpu/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/bert
    data_dir=${data}bert/
    link_data ${data_dir}
    sed -i 's/8860/8861/g' bert_client.py
Z
zhangyulong04 已提交
434
    ${py_version} -m paddle_serving_server.serve --model bert_seq128_model/ --port 8861 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
435
    check_result server 5
Z
Zhang Yulong 已提交
436
    cp data-c.txt.1 data-c.txt
Z
zhangyulong04 已提交
437
    head data-c.txt | ${py_version} bert_client.py --model bert_seq128_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
438 439 440 441 442 443 444 445 446 447 448
    check_result client "bert_CPU_RPC server test completed"
    kill_server_process
}

function pipeline_imagenet() {
    dir=${log_dir}rpc_model/pipeline_imagenet/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/pipeline/imagenet
    data_dir=${data}imagenet/
    link_data ${data_dir}
Z
zhangyulong04 已提交
449
    ${py_version} resnet50_web_service.py > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
450
    check_result server 8
Z
Zhang Yulong 已提交
451
    nvidia-smi
Z
zhangyulong04 已提交
452
    timeout 30s ${py_version} pipeline_rpc_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
453
    echo "pipeline_log:-----------"
Z
Zhang Yulong 已提交
454 455 456 457 458 459 460 461 462 463 464 465 466
    check_result client "pipeline_imagenet_GPU_RPC server test completed"
    nvidia-smi
    kill_server_process
}

function ResNet50_rpc() {
    dir=${log_dir}rpc_model/ResNet50_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imagenet
    data_dir=${data}imagenet/
    link_data ${data_dir}
    sed -i 's/9696/8863/g' resnet50_rpc_client.py
Z
zhangyulong04 已提交
467
    ${py_version} -m paddle_serving_server.serve --model ResNet50_vd_model --port 8863 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
468
    check_result server 8
Z
ZhangYulongg 已提交
469
    check_gpu_memory 0
Z
Zhang Yulong 已提交
470
    nvidia-smi
Z
zhangyulong04 已提交
471
    ${py_version} resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
472 473 474 475 476 477 478 479 480 481 482 483 484
    check_result client "ResNet50_GPU_RPC server test completed"
    nvidia-smi
    kill_server_process
}

function ResNet101_rpc() {
    dir=${log_dir}rpc_model/ResNet101_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imagenet
    data_dir=${data}imagenet/
    link_data ${data_dir}
    sed -i "22cclient.connect(['127.0.0.1:8864'])" image_rpc_client.py
Z
zhangyulong04 已提交
485
    ${py_version} -m paddle_serving_server.serve --model ResNet101_vd_model --port 8864 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
486
    check_result server 8
Z
ZhangYulongg 已提交
487
    check_gpu_memory 0
Z
Zhang Yulong 已提交
488
    nvidia-smi
Z
zhangyulong04 已提交
489
    ${py_version} image_rpc_client.py ResNet101_vd_client_config/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
490 491 492 493 494
    check_result client "ResNet101_GPU_RPC server test completed"
    nvidia-smi
    kill_server_process
}

Z
add  
ZhangYulongg 已提交
495
function cnn_rpc_asyn() {
Z
Zhang Yulong 已提交
496 497 498 499 500 501 502
    dir=${log_dir}rpc_model/cnn_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
    data_dir=${data}imdb/
    link_data ${data_dir}
    sed -i 's/9292/8865/g' test_client.py
Z
add  
ZhangYulongg 已提交
503 504 505
    ${py_version} -m paddle_serving_server.serve --model imdb_cnn_model/ --port 8865 --op_num 4 --thread 10 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
    check_result server 8
    check_gpu_memory 0
Z
zhangyulong04 已提交
506
    head test_data/part-0 | ${py_version} test_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
507 508 509 510 511 512 513 514 515 516 517 518
    check_result client "cnn_CPU_RPC server test completed"
    kill_server_process
}

function bow_rpc() {
    dir=${log_dir}rpc_model/bow_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
    data_dir=${data}imdb/
    link_data ${data_dir}
    sed -i 's/8865/8866/g' test_client.py
Z
zhangyulong04 已提交
519
    ${py_version} -m paddle_serving_server.serve --model imdb_bow_model/ --port 8866 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
520
    check_result server 5
Z
zhangyulong04 已提交
521
    head test_data/part-0 | ${py_version} test_client.py imdb_bow_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
522 523 524 525 526 527 528 529 530 531 532 533
    check_result client "bow_CPU_RPC server test completed"
    kill_server_process
}

function lstm_rpc() {
    dir=${log_dir}rpc_model/lstm_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
    data_dir=${data}imdb/
    link_data ${data_dir}
    sed -i 's/8866/8867/g' test_client.py
Z
zhangyulong04 已提交
534
    ${py_version} -m paddle_serving_server.serve --model imdb_lstm_model/ --port 8867 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
535
    check_result server 5
Z
zhangyulong04 已提交
536
    head test_data/part-0 | ${py_version} test_client.py imdb_lstm_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
537 538 539 540
    check_result client "lstm_CPU_RPC server test completed"
    kill_server_process
}

Z
add  
ZhangYulongg 已提交
541
function lac_rpc_asyn() {
Z
Zhang Yulong 已提交
542 543 544 545 546 547 548
    dir=${log_dir}rpc_model/lac_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/lac
    data_dir=${data}lac/
    link_data ${data_dir}
    sed -i 's/9292/8868/g' lac_client.py
Z
add  
ZhangYulongg 已提交
549 550 551
    ${py_version} -m paddle_serving_server.serve --model lac_model/ --port 8868 --gpu_ids 0 --op_num 2 > ${dir}server_log.txt 2>&1 &
    check_result server 8
    check_gpu_memory 0
Z
zhangyulong04 已提交
552
    echo "我爱北京天安门" | ${py_version} lac_client.py lac_client/serving_client_conf.prototxt lac_dict/ > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
553 554 555 556 557 558 559 560 561 562 563 564
    check_result client "lac_CPU_RPC server test completed"
    kill_server_process
}

function fit_a_line_rpc() {
    dir=${log_dir}rpc_model/fit_a_line_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/fit_a_line
    data_dir=${data}fit_a_line/
    link_data ${data_dir}
    sed -i 's/9393/8869/g' test_client.py
Z
zhangyulong04 已提交
565
    ${py_version} -m paddle_serving_server.serve --model uci_housing_model --port 8869 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
566
    check_result server 5
Z
zhangyulong04 已提交
567
    ${py_version} test_client.py uci_housing_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
568 569 570 571 572 573 574 575 576 577 578 579
    check_result client "fit_a_line_CPU_RPC server test completed"
    kill_server_process
}

function faster_rcnn_model_rpc() {
    dir=${log_dir}rpc_model/faster_rcnn_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/detection/faster_rcnn_r50_fpn_1x_coco
    data_dir=${data}detection/faster_rcnn_r50_fpn_1x_coco/
    link_data ${data_dir}
    sed -i 's/9494/8870/g' test_client.py
Z
ZhangYulongg 已提交
580
    ${py_version} -m paddle_serving_server.serve --model serving_server --port 8870 --gpu_ids 1 --thread 8 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
581 582 583
    echo "faster rcnn running ..."
    nvidia-smi
    check_result server 10
Z
ZhangYulongg 已提交
584
    check_gpu_memory 1
Z
zhangyulong04 已提交
585
    ${py_version} test_client.py 000000570688.jpg > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
586 587 588 589 590 591 592 593 594 595 596 597 598
    nvidia-smi
    check_result client "faster_rcnn_GPU_RPC server test completed"
    kill_server_process
}

function cascade_rcnn_rpc() {
    dir=${log_dir}rpc_model/cascade_rcnn_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/cascade_rcnn
    data_dir=${data}cascade_rcnn/
    link_data ${data_dir}
    sed -i "s/9292/8879/g" test_client.py
Z
zhangyulong04 已提交
599
    ${py_version} -m paddle_serving_server.serve --model serving_server --port 8879 --gpu_ids 0 --thread 2 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
600
    check_result server 8
Z
ZhangYulongg 已提交
601
    check_gpu_memory 0
Z
Zhang Yulong 已提交
602
    nvidia-smi
Z
zhangyulong04 已提交
603
    ${py_version} test_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
604 605 606
    nvidia-smi
    check_result client "cascade_rcnn_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
607 608 609
}

function deeplabv3_rpc() {
Z
Zhang Yulong 已提交
610 611 612 613 614 615 616
    dir=${log_dir}rpc_model/deeplabv3_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/deeplabv3
    data_dir=${data}deeplabv3/
    link_data ${data_dir}
    sed -i "s/9494/8880/g" deeplabv3_client.py
Z
ZhangYulongg 已提交
617
    ${py_version} -m paddle_serving_server.serve --model deeplabv3_server --gpu_ids 0 --port 8880 --thread 4 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
618
    check_result server 10
Z
ZhangYulongg 已提交
619
    check_gpu_memory 0
Z
Zhang Yulong 已提交
620
    nvidia-smi
Z
zhangyulong04 已提交
621
    ${py_version} deeplabv3_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
622 623 624
    nvidia-smi
    check_result client "deeplabv3_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
625 626 627
}

function mobilenet_rpc() {
Z
Zhang Yulong 已提交
628 629 630 631
    dir=${log_dir}rpc_model/mobilenet_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/mobilenet
Z
zhangyulong04 已提交
632
    ${py_version} -m paddle_serving_app.package --get_model mobilenet_v2_imagenet >/dev/null 2>&1
Z
Zhang Yulong 已提交
633 634
    tar xf mobilenet_v2_imagenet.tar.gz
    sed -i "s/9393/8881/g" mobilenet_tutorial.py
Z
zhangyulong04 已提交
635
    ${py_version} -m paddle_serving_server.serve --model mobilenet_v2_imagenet_model --gpu_ids 0 --port 8881 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
636
    check_result server 8
Z
ZhangYulongg 已提交
637
    check_gpu_memory 0
Z
Zhang Yulong 已提交
638
    nvidia-smi
Z
zhangyulong04 已提交
639
    ${py_version} mobilenet_tutorial.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
640 641 642
    nvidia-smi
    check_result client "mobilenet_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
643 644 645
}

function unet_rpc() {
Z
Zhang Yulong 已提交
646 647 648 649 650 651 652
    dir=${log_dir}rpc_model/unet_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/unet_for_image_seg
    data_dir=${data}unet_for_image_seg/
    link_data ${data_dir}
    sed -i "s/9494/8882/g" seg_client.py
Z
ZhangYulongg 已提交
653
    ${py_version} -m paddle_serving_server.serve --model unet_model --gpu_ids 1 --port 8882 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
654
    check_result server 8
Z
ZhangYulongg 已提交
655
    check_gpu_memory 1
Z
Zhang Yulong 已提交
656
    nvidia-smi
Z
zhangyulong04 已提交
657
    ${py_version} seg_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
658 659 660
    nvidia-smi
    check_result client "unet_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
661 662 663
}

function resnetv2_rpc() {
Z
Zhang Yulong 已提交
664 665 666 667 668 669 670
    dir=${log_dir}rpc_model/resnetv2_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/resnet_v2_50
    data_dir=${data}resnet_v2_50/
    link_data ${data_dir}
    sed -i 's/9393/8883/g' resnet50_v2_tutorial.py
Z
zhangyulong04 已提交
671
    ${py_version} -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --gpu_ids 0 --port 8883 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
672
    check_result server 10
Z
ZhangYulongg 已提交
673
    check_gpu_memory 0
Z
Zhang Yulong 已提交
674
    nvidia-smi
Z
zhangyulong04 已提交
675
    ${py_version} resnet50_v2_tutorial.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
676 677 678
    nvidia-smi
    check_result client "resnetv2_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
679 680 681
}

function ocr_rpc() {
Z
Zhang Yulong 已提交
682 683 684 685 686 687
    dir=${log_dir}rpc_model/ocr_rpc/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/ocr
    data_dir=${data}ocr/
    link_data ${data_dir}
Z
zhangyulong04 已提交
688
    ${py_version} -m paddle_serving_app.package --get_model ocr_rec >/dev/null 2>&1
Z
Zhang Yulong 已提交
689 690
    tar xf ocr_rec.tar.gz
    sed -i 's/9292/8884/g' test_ocr_rec_client.py
Z
zhangyulong04 已提交
691
    ${py_version} -m paddle_serving_server.serve --model ocr_rec_model --port 8884 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
692
    check_result server 5
Z
zhangyulong04 已提交
693
    ${py_version} test_ocr_rec_client.py > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
694 695
    check_result client "ocr_CPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
696 697 698
}

function criteo_ctr_rpc_cpu() {
Z
Zhang Yulong 已提交
699 700 701 702 703 704 705
    dir=${log_dir}rpc_model/criteo_ctr_rpc_cpu/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/criteo_ctr
    data_dir=${data}criteo_ctr/
    link_data ${data_dir}
    sed -i "s/9292/8885/g" test_client.py
Z
zhangyulong04 已提交
706
    ${py_version} -m paddle_serving_server.serve --model ctr_serving_model/ --port 8885 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
707
    check_result server 5
Z
zhangyulong04 已提交
708
    ${py_version} test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0 > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
709 710
    check_result client "criteo_ctr_CPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
711 712 713
}

function criteo_ctr_rpc_gpu() {
Z
Zhang Yulong 已提交
714 715 716 717 718 719 720
    dir=${log_dir}rpc_model/criteo_ctr_rpc_gpu/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/criteo_ctr
    data_dir=${data}criteo_ctr/
    link_data ${data_dir}
    sed -i "s/8885/8886/g" test_client.py
Z
ZhangYulongg 已提交
721
    ${py_version} -m paddle_serving_server.serve --model ctr_serving_model/ --port 8886 --gpu_ids 1 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
722
    check_result server 8
Z
ZhangYulongg 已提交
723
    check_gpu_memory 1
Z
Zhang Yulong 已提交
724
    nvidia-smi
Z
zhangyulong04 已提交
725
    ${py_version} test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0 > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
726 727 728
    nvidia-smi
    check_result client "criteo_ctr_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
729 730 731
}

function yolov4_rpc_gpu() {
Z
Zhang Yulong 已提交
732 733 734 735 736 737 738
    dir=${log_dir}rpc_model/yolov4_rpc_gpu/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/yolov4
    data_dir=${data}yolov4/
    link_data ${data_dir}
    sed -i "s/9393/8887/g" test_client.py
Z
zhangyulong04 已提交
739
    ${py_version} -m paddle_serving_server.serve --model yolov4_model --port 8887 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
740
    nvidia-smi
Z
Zhang Yulong 已提交
741
    check_result server 8
Z
ZhangYulongg 已提交
742
    check_gpu_memory 0
Z
zhangyulong04 已提交
743
    ${py_version} test_client.py 000000570688.jpg > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
744 745 746
    nvidia-smi
    check_result client "yolov4_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
747 748 749
}

function senta_rpc_cpu() {
Z
Zhang Yulong 已提交
750 751 752 753 754 755 756
    dir=${log_dir}rpc_model/senta_rpc_cpu/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/senta
    data_dir=${data}senta/
    link_data ${data_dir}
    sed -i "s/9393/8887/g" test_client.py
Z
zhangyulong04 已提交
757
    ${py_version} -m paddle_serving_server.serve --model yolov4_model --port 8887 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
758
    nvidia-smi
Z
Zhang Yulong 已提交
759
    check_result server 8
Z
ZhangYulongg 已提交
760
    check_gpu_memory 0
Z
zhangyulong04 已提交
761
    ${py_version} test_client.py 000000570688.jpg > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
762 763 764
    nvidia-smi
    check_result client "senta_GPU_RPC server test completed"
    kill_server_process
L
liyang109 已提交
765 766 767 768
}


function fit_a_line_http() {
Z
Zhang Yulong 已提交
769 770 771 772
    dir=${log_dir}http_model/fit_a_line_http/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/fit_a_line
Z
ZhangYulongg 已提交
773
    ${py_version} -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
774
    check_result server 10
Z
ZhangYulongg 已提交
775
    ${py_version} test_httpclient.py uci_housing_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
776 777
    check_result client "fit_a_line_CPU_HTTP server test completed"
    kill_server_process
L
liyang109 已提交
778 779 780
}

function lac_http() {
Z
Zhang Yulong 已提交
781 782 783 784
    dir=${log_dir}http_model/lac_http/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/lac
Z
ZhangYulongg 已提交
785
    ${py_version} -m paddle_serving_server.serve --model lac_model/ --port 9292 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
786
    check_result server 10
Z
ZhangYulongg 已提交
787
    echo "我爱北京天安门" | ${py_version} lac_http_client.py lac_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
788 789
    check_result client "lac_CPU_HTTP server test completed"
    kill_server_process
L
liyang109 已提交
790 791
}

Z
ZhangYulongg 已提交
792 793
function imdb_http_proto() {
    dir=${log_dir}http_model/imdb_http_proto/
Z
Zhang Yulong 已提交
794 795 796
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
Z
ZhangYulongg 已提交
797
    ${py_version} -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
798
    check_result server 10
Z
ZhangYulongg 已提交
799 800
    head test_data/part-0 | ${py_version} test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
    check_result client "imdb_CPU_HTTP-proto server test completed"
Z
Zhang Yulong 已提交
801
    kill_server_process
L
liyang109 已提交
802 803
}

Z
ZhangYulongg 已提交
804 805
function imdb_http_json() {
    dir=${log_dir}http_model/imdb_http_json/
Z
Zhang Yulong 已提交
806 807 808
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
Z
ZhangYulongg 已提交
809
    ${py_version} -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
810
    check_result server 10
Z
ZhangYulongg 已提交
811 812 813
    sed -i "s/#client.set_http_proto(True)/client.set_http_proto(False)/g" test_http_client.py
    head test_data/part-0 | ${py_version} test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
    check_result client "imdb_CPU_HTTP-json server test completed"
Z
Zhang Yulong 已提交
814
    kill_server_process
L
liyang109 已提交
815 816
}

Z
ZhangYulongg 已提交
817 818
function imdb_grpc() {
    dir=${log_dir}http_model/imdb_grpc/
Z
Zhang Yulong 已提交
819 820 821
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imdb
Z
ZhangYulongg 已提交
822
    ${py_version} -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292 --gpu_ids 1 > ${dir}server_log.txt 2>&1 &
Z
Zhang Yulong 已提交
823
    check_result server 10
Z
ZhangYulongg 已提交
824 825 826 827 828
    check_gpu_memory 1
    sed -i "s/client.set_http_proto(False)/#client.set_http_proto(False)/g" test_http_client.py
    sed -i "s/#client.set_use_grpc_client(True)/client.set_use_grpc_client(True)/g" test_http_client.py
    head test_data/part-0 | ${py_version} test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab > ${dir}client_log.txt 2>&1
    check_result client "imdb_GPU_GRPC server test completed"
Z
Zhang Yulong 已提交
829
    kill_server_process
L
liyang109 已提交
830 831 832
}

function ResNet50_http() {
Z
ZhangYulongg 已提交
833 834 835 836 837 838 839 840 841 842
    dir=${log_dir}http_model/ResNet50_http/
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/imagenet
    ${py_version} -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
    check_result server 10
    check_gpu_memory 0
    ${py_version} resnet50_http_client.py ResNet50_vd_client_config/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
    check_result client "ResNet50_GPU_HTTP server test completed"
    kill_server_process
Z
Zhang Yulong 已提交
843 844 845
}

function bert_http() {
Z
ZhangYulongg 已提交
846
    dir=${log_dir}http_model/bert_http/
Z
Zhang Yulong 已提交
847 848 849 850 851
    check_dir ${dir}
    unsetproxy
    cd ${build_path}/python/examples/bert
    cp data-c.txt.1 data-c.txt
    cp vocab.txt.1 vocab.txt
Z
ZhangYulongg 已提交
852 853 854 855 856
    export CUDA_VISIBLE_DEVICES=0,1
    ${py_version} -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --gpu_ids 0 > ${dir}server_log.txt 2>&1 &
    check_result server 10
    check_gpu_memory 0
    head data-c.txt | ${py_version} bert_httpclient.py --model bert_seq128_client/serving_client_conf.prototxt > ${dir}client_log.txt 2>&1
Z
Zhang Yulong 已提交
857 858 859 860 861
    check_result client "bert_GPU_HTTP server test completed"
    kill_server_process
}

function grpc_fit_a_line() {
Z
close  
ZhangYulongg 已提交
862
    echo "pass"
Z
ZhangYulongg 已提交
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
#    dir=${log_dir}rpc_model/grpc_fit_a_line/
#    check_dir ${dir}
#    unsetproxy
#    cd ${build_path}/python/examples/grpc_impl_example/fit_a_line
#    data_dir=${data}fit_a_line/
#    link_data ${data_dir}
#    ${py_version} test_server.py uci_housing_model/ > ${dir}server_log.txt 2>&1 &
#    check_result server 5
#    echo "sync predict" > ${dir}client_log.txt 2>&1
#    ${py_version} test_sync_client.py >> ${dir}client_log.txt 2>&1
#    check_result client "grpc_impl_example_fit_a_line_sync_CPU_gRPC server sync test completed"
#    echo "async predict" >> ${dir}client_log.txt 2>&1
#    ${py_version} test_asyn_client.py >> ${dir}client_log.txt 2>&1
#    check_result client "grpc_impl_example_fit_a_line_asyn_CPU_gRPC server asyn test completed"
#    echo "batch predict" >> ${dir}client_log.txt 2>&1
#    ${py_version} test_batch_client.py >> ${dir}client_log.txt 2>&1
#    check_result client "grpc_impl_example_fit_a_line_batch_CPU_gRPC server batch test completed"
#    echo "timeout predict" >> ${dir}client_log.txt 2>&1
#    ${py_version} test_timeout_client.py >> ${dir}client_log.txt 2>&1
#    check_result client "grpc_impl_example_fit_a_line_timeout_CPU_gRPC server timeout test completed"
#    kill_server_process
Z
Zhang Yulong 已提交
884 885 886
}

function grpc_yolov4() {
Z
close  
ZhangYulongg 已提交
887
    echo "pass"
Z
ZhangYulongg 已提交
888 889 890 891 892 893 894 895 896 897 898 899 900
#    dir=${log_dir}rpc_model/grpc_yolov4/
#    cd ${build_path}/python/examples/grpc_impl_example/yolov4
#    check_dir ${dir}
#    data_dir=${data}yolov4/
#    link_data ${data_dir}
#    echo -e "${GREEN_COLOR}grpc_impl_example_yolov4_GPU_gRPC server started${RES}"
#    ${py_version} -m paddle_serving_server.serve --model yolov4_model --port 9393 --gpu_ids 0 --use_multilang > ${dir}server_log.txt 2>&1 &
#    check_result server 15
#    check_gpu_memory 0
#    echo -e "${GREEN_COLOR}grpc_impl_example_yolov4_GPU_gRPC client started${RES}"
#    ${py_version} test_client.py 000000570688.jpg > ${dir}client_log.txt 2>&1
#    check_result client "grpc_yolov4_GPU_GRPC server test completed"
#    kill_server_process
Z
Zhang Yulong 已提交
901 902
}

Z
zhangyulong04 已提交
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
function ocr_c++_service() {
    dir=${log_dir}rpc_model/ocr_c++_serving/
    cd ${build_path}/python/examples/ocr
    check_dir ${dir}
    data_dir=${data}ocr/
    link_data ${data_dir}
    cp -r ocr_det_client/ ./ocr_det_client_cp
    rm -rf ocr_det_client
    mv ocr_det_client_cp ocr_det_client
    sed -i "s/feed_type: 1/feed_type: 3/g" ocr_det_client/serving_client_conf.prototxt
    sed -i "s/shape: 3/shape: 1/g" ocr_det_client/serving_client_conf.prototxt
    sed -i '7,8d' ocr_det_client/serving_client_conf.prototxt
    echo -e "${GREEN_COLOR}OCR_C++_Service_GPU_RPC server started${RES}"
    $py_version -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_id 0 > ${dir}server_log.txt 2>&1 &
    check_result server 8
Z
ZhangYulongg 已提交
918
    check_gpu_memory 0
Z
zhangyulong04 已提交
919 920 921 922 923 924 925 926 927
    echo -e "${GREEN_COLOR}OCR_C++_Service_GPU_RPC client started${RES}"
    echo "------------------first:"
    $py_version ocr_cpp_client.py ocr_det_client ocr_rec_client
    echo "------------------second:"
    $py_version ocr_cpp_client.py ocr_det_client ocr_rec_client > ${dir}client_log.txt 2>&1
    check_result client "OCR_C++_Service_GPU_RPC server test completed"
    kill_server_process
}

Z
add  
ZhangYulongg 已提交
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944
function ocr_c++_service_asyn() {
    dir=${log_dir}rpc_model/ocr_c++_serving/
    cd ${build_path}/python/examples/ocr
    check_dir ${dir}
    echo -e "${GREEN_COLOR}OCR_C++_Service_GPU_RPC asyn_server started${RES}"
    $py_version -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_id 0 --op_num 4 > ${dir}server_log.txt 2>&1 &
    check_result server 8
    check_gpu_memory 0
    echo -e "${GREEN_COLOR}OCR_C++_Service_GPU_RPC client started${RES}"
    echo "------------------first:"
    $py_version ocr_cpp_client.py ocr_det_client ocr_rec_client
    echo "------------------second:"
    $py_version ocr_cpp_client.py ocr_det_client ocr_rec_client > ${dir}client_log.txt 2>&1
    check_result client "OCR_C++_Service_GPU_RPC server test completed"
    kill_server_process
}

Z
Zhang Yulong 已提交
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
function build_all_whl() {
    for whl in ${build_whl_list[@]}
    do
        echo "===========${whl} begin build==========="
        $whl
        sleep 3
        echo "===========${whl} build over ==========="
    done
}

function run_rpc_models() {
    for model in ${rpc_model_list[@]}
    do
        echo "===========${model} run begin==========="
        $model
        sleep 3
        echo "===========${model} run  end ==========="
    done
}

function run_http_models() {
    for model in ${http_model_list[@]}
    do
        echo "===========${model} run begin==========="
        $model
        sleep 3
        echo "===========${model} run  end ==========="
    done
}

function end_hook() {
    cd ${build_path}
    kill_server_process
    kill `ps -ef|grep python|awk '{print $2}'`
    sleep 5
    echo "===========files==========="
    ls -hlst
    echo "=========== end ==========="
L
liyang109 已提交
983 984 985
}

function main() {
Z
zhangyulong04 已提交
986
    set_env $1 $2
Z
Zhang Yulong 已提交
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
    before_hook
    build_all_whl
    check
    run_env
    unsetproxy
    run_gpu_env
    check_dir ${log_dir}rpc_model/
    check_dir ${log_dir}http_model/
    check_dir ${log_dir}error/
    run_rpc_models
    run_http_models
    end_hook
    if [ -f ${log_dir}error_models.txt ]; then
        cat ${log_dir}error_models.txt
        echo "error occurred!"
Z
Zhang Yulong 已提交
1002
        exit 1
Z
Zhang Yulong 已提交
1003
    fi
L
liyang109 已提交
1004 1005
}

Z
zhangyulong04 已提交
1006
main $@