(简体中文|English)
Paddle Serving支持使用百度昆仑芯片进行预测部署。目前支持在百度昆仑芯片和arm服务器(如飞腾 FT-2000+/64), 或者百度昆仑芯片和Intel CPU服务器,上进行部署,后续完善对其他异构硬件服务器部署能力。
我们推荐使用docker部署Serving服务,在xpu环境下可参考Docker镜像文档安装xpu镜像,并进一步完成编译、安装和部署等任务。
基本环境配置可参考该文档进行配置。下面以飞腾FT-2000+/64机器为例进行介绍。
cd Serving
mkdir -p server-build-arm && cd server-build-arm
cmake -DPYTHON_INCLUDE_DIR=/usr/local/include/python3.7m/ \
-DPYTHON_LIBRARIES=/usr/local/lib/ \
-DPYTHON_EXECUTABLE=/usr/local/bin/python3.7 \
-DWITH_PYTHON=ON \
-DWITH_LITE=ON \
-DWITH_XPU=ON \
-DWITH_MKL=ON \
-DSERVER=ON ..
make -j10
可以执行make install
把目标产出放在./output
目录下,cmake阶段需添加-DCMAKE_INSTALL_PREFIX=./output
选项来指定存放路径。在支持AVX2指令集的Intel CPU平台上请指定-DWITH_MKL=ON
编译选项。
mkdir -p client-build-arm && cd client-build-arm
cmake -DPYTHON_INCLUDE_DIR=/usr/local/include/python3.7m/ \
-DPYTHON_LIBRARIES=/usr/local/lib/ \
-DPYTHON_EXECUTABLE=/usr/local/bin/python3.7 \
-DWITH_PYTHON=ON \
-DWITH_LITE=ON \
-DWITH_XPU=ON \
-DCLIENT=ON ..
make -j10
cd Serving
mkdir -p app-build-arm && cd app-build-arm
cmake -DPYTHON_INCLUDE_DIR=/usr/local/include/python3.7m/ \
-DPYTHON_LIBRARIES=/usr/local/lib/ \
-DPYTHON_EXECUTABLE=/usr/local/bin/python3.7 \
-DWITH_PYTHON=ON \
-DWITH_LITE=ON \
-DWITH_XPU=ON \
-DAPP=ON ..
make -j10
以上编译步骤完成后,会在各自编译目录$build_dir/python/dist生成whl包,分别安装即可。例如server步骤,会在server-build-arm/python/dist目录下生成whl包, 使用命令pip install -u xxx.whl
进行安装。
为了支持arm+xpu服务部署,使用Paddle-Lite加速能力,请求时需使用以下参数。
参数 | 参数说明 | 备注 |
---|---|---|
use_lite | 使用Paddle-Lite Engine | 使用Paddle-Lite cpu预测能力 |
use_xpu | 使用Baidu Kunlun进行预测 | 该选项需要与use_lite配合使用 |
ir_optim | 开启Paddle-Lite计算子图优化 | 详细见Paddle-Lite |
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz
tar -xzf uci_housing.tar.gz
主要有三种启动配置:
推荐使用前两种部署方式。
启动rpc服务,使用cpu+xpu部署,使用Paddle-Lite xpu优化加速能力
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 6 --port 9292 --use_lite --use_xpu --ir_optim
启动rpc服务,使用cpu部署, 使用Paddle-Lite加速能力
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 6 --port 9292 --use_lite --ir_optim
启动rpc服务,使用cpu部署, 不使用Paddle-Lite加速能力
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 6 --port 9292
from paddle_serving_client import Client
import numpy as np
client = Client()
client.load_client_config("uci_housing_client/serving_client_conf.prototxt")
client.connect(["127.0.0.1:9292"])
data = [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727,
-0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]
fetch_map = client.predict(feed={"x": np.array(data).reshape(1,13,1)}, fetch=["price"])
print(fetch_map)
以下提供部分样例,其他模型可参照进行修改。
示例名称 | 示例链接 |
---|---|
fit_a_line | fit_a_line_xpu |
resnet | resnet_v2_50_xpu |
注:支持昆仑芯片部署模型列表见链接。不同模型适配上存在差异,可能存在不支持的情况,部署使用存在问题时,欢迎以Github issue,我们会实时跟进。
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》