Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
f35557de
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f35557de
编写于
3月 16, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add doc: RUN_IN_DOCKER.md & RUN_IN_DOCKER_CN.md
上级
7735fbf9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
391 addition
and
33 deletion
+391
-33
doc/RUN_IN_DOCKER.md
doc/RUN_IN_DOCKER.md
+176
-0
doc/RUN_IN_DOCKER_CN.md
doc/RUN_IN_DOCKER_CN.md
+172
-0
tools/Dockerfile
tools/Dockerfile
+7
-23
tools/Dockerfile.devel
tools/Dockerfile.devel
+22
-0
tools/Dockerfile.gpu
tools/Dockerfile.gpu
+14
-10
未找到文件。
doc/RUN_IN_DOCKER.md
0 → 100644
浏览文件 @
f35557de
# How to run PaddleServing in Docker
## Requirements
Docker (GPU version requires nvidia-docker to be installed on the GPU machine)
## CPU
### Get docker image
You can get images in two ways:
1.
Pull image directly
```
bash
docker pull hub.baidubce.com/ctr/paddleserving:0.1.3
```
2.
Building image based on dockerfile
Create a new folder and copy
[
Dockerfile
](
../Dockerfile
)
to this folder, and run the following command:
```
bash
docker build
-t
hub.baidubce.com/ctr/paddleserving:0.1.3 .
```
### Create container
```
bash
docker run
-p
9292:9292
--name
test
-dit
hub.baidubce.com/ctr/paddleserving:0.1.3
docker
exec
-it
test
bash
```
The
`-p`
option is to map the
`9292`
port of the container to the
`9292`
port of the host.
### Install PaddleServing
In order to make the image smaller, the PaddleServing package is not installed in the image. You can run the following command to install it
```
bash
pip
install
paddle-serving-server
```
### Test example
Get the trained Boston house price prediction model by the following command:
```
bash
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz
tar
-xzf
uci_housing.tar.gz
```
-
Test HTTP service
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server.web_serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci &>std.log 2>err.log &
```
Running on the Client side (inside or outside the container):
```
bash
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"x": [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":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
-
Test RPC service
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9292 &>std.log 2>err.log &
```
Running following Python code on the Client side (inside or outside the container, The
`paddle-serving-client`
package needs to be installed):
```
bash
from paddle_serving_client import Client
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"
: data
}
,
fetch
=[
"price"
])
print
(
fetch_map
)
```
## GPU
The GPU version is basically the same as the CPU version, with only some differences in interface naming (GPU version requires nvidia-docker to be installed on the GPU machine).
### Get docker image
You can also get images in two ways:
1.
Pull image directly
```
bash
nvidia-docker pull hub.baidubce.com/ctr/paddleserving:0.1.3-gpu
```
2.
Building image based on dockerfile
Create a new folder and copy
[
Dockerfile.gpu
](
../Dockerfile.gpu
)
to this folder, and run the following command:
```
bash
nvidia-docker build
-t
hub.baidubce.com/ctr/paddleserving:0.1.3-gpu .
```
### Create container
```
bash
nvidia-docker run
-p
9292:9292
--name
test
-dit
hub.baidubce.com/ctr/paddleserving:0.1.3-gpu
nvidia-docker
exec
-it
test
bash
```
The
`-p`
option is to map the
`9292`
port of the container to the
`9292`
port of the host.
### Install PaddleServing
In order to make the image smaller, the PaddleServing package is not installed in the image. You can run the following command to install it:
```
bash
pip
install
paddle-serving-server-gpu
```
### Test example
Get the trained Boston house price prediction model by the following command:
```
bash
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz
tar
-xzf
uci_housing.tar.gz
```
-
Test HTTP service
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server_gpu.web_serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
```
Running on the Client side (inside or outside the container):
```
bash
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"x": [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":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
-
Test RPC service
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
```
Running following Python code on the Client side (inside or outside the container, The
`paddle-serving-client`
package needs to be installed):
```
bash
from paddle_serving_client import Client
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"
: data
}
,
fetch
=[
"price"
])
print
(
fetch_map
)
```
doc/RUN_IN_DOCKER_CN.md
0 → 100644
浏览文件 @
f35557de
# 如何在Docker中运行PaddleServing
## 环境要求
Docker(GPU版本需要在GPU机器上安装nvidia-docker)
## CPU版本
### 获取镜像
可以通过两种方式获取镜像。
1.
直接拉取镜像
```
bash
docker pull hub.baidubce.com/ctr/paddleserving:0.1.3
```
2.
基于Dockerfile构建镜像
建立新目录,复制
[
Dockerfile
](
../Dockerfile
)
内容到该目录下Dockerfile文件。执行
```
bash
docker build
-t
hub.baidubce.com/ctr/paddleserving:0.1.3 .
```
### 创建容器并进入
```
bash
docker run
-p
9292:9292
--name
test
-dit
hub.baidubce.com/ctr/paddleserving:0.1.3
docker
exec
-it
test
bash
```
`-p`
选项是为了将容器的
`9292`
端口映射到宿主机的
`9292`
端口。
### 安装PaddleServing
为了减小镜像的体积,镜像中没有安装Serving包,要执行下面命令进行安装
```
bash
pip
install
paddle-serving-server
```
### 测试example
通过下面命令获取训练好的Boston房价预估模型:
```
bash
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz
tar
-xzf
uci_housing.tar.gz
```
-
测试HTTP服务
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server.web_serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci &>std.log 2>err.log &
```
在Client端(容器内或容器外)运行:
```
bash
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"x": [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":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
-
测试RPC服务
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server.serve
--model
uci_housing_model
--thread
10
--port
9292 &>std.log 2>err.log &
```
在Client端(容器内或容器外,需要安装
`paddle-serving-client`
包)运行下面Python代码:
```
python
from
paddle_serving_client
import
Client
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"
:
data
},
fetch
=
[
"price"
])
print
(
fetch_map
)
```
## GPU版本
GPU版本与CPU版本基本一致,只有部分接口命名的差别(GPU版本需要在GPU机器上安装nvidia-docker)。
### 获取镜像
可以通过两种方式获取镜像。
1.
直接拉取镜像
```
bash
nvidia-docker pull hub.baidubce.com/ctr/paddleserving:0.1.3-gpu
```
2.
基于Dockerfile构建镜像
建立新目录,复制
[
Dockerfile.gpu
](
../Dockerfile.gpu
)
内容到该目录下Dockerfile文件。执行
```
bash
nvidia-docker build
-t
hub.baidubce.com/ctr/paddleserving:0.1.3-gpu .
```
### 创建容器并进入
```
bash
nvidia-docker run
-p
9292:9292
--name
test
-dit
hub.baidubce.com/ctr/paddleserving:0.1.3-gpu
nvidia-docker
exec
-it
test
bash
```
`-p`
选项是为了将容器的
`9292`
端口映射到宿主机的
`9292`
端口。
### 安装PaddleServing
为了减小镜像的体积,镜像中没有安装Serving包,要执行下面命令进行安装
```
bash
pip
install
paddle-serving-server-gpu
```
### 测试example
通过下面命令获取训练好的Boston房价预估模型:
```
bash
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/uci_housing.tar.gz
tar
-xzf
uci_housing.tar.gz
```
-
测试HTTP服务
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server_gpu.web_serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
```
在Client端(容器内或容器外)运行:
```
bash
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"x": [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":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
-
测试RPC服务
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
```
在Client端(容器内或容器外,需要安装
`paddle-serving-client`
包)运行下面Python代码:
```
bash
from paddle_serving_client import Client
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"
: data
}
,
fetch
=[
"price"
])
print
(
fetch_map
)
```
tools/Dockerfile
浏览文件 @
f35557de
FROM
centos:centos6.10
RUN
yum
-y
install
wget
\
&&
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
-O
/etc/yum.repos.d/devtoolset-2.repo
\
&&
yum
-y
install
devtoolset-2-gcc devtoolset-2-gcc-c++ devtoolset-2-binutils
\
&&
source
/opt/rh/devtoolset-2/enable
\
&&
echo
"source /opt/rh/devtoolset-2/enable"
>>
/etc/profile
\
&&
yum
-y
install
git openssl-devel curl-devel bzip2-devel
\
&&
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
\
&&
tar
xvf cmake-3.5.2.tar.gz
\
&&
cd
cmake-3.5.2
\
&&
./bootstrap
--prefix
=
/usr
\
&&
make
\
&&
make
install
\
&&
cd
..
\
&&
rm
-r
cmake-3.5.2
*
\
&&
wget https://dl.google.com/go/go1.12.12.linux-amd64.tar.gz
\
&&
tar
-xzvf
go1.12.12.linux-amd64.tar.gz
\
&&
mv
go /usr/local/go
\
&&
rm
go1.12.12.linux-amd64.tar.gz
\
&&
echo
"export GOROOT=/usr/local/go"
>>
/root/.bashrc
\
&&
echo
"export GOPATH=
$HOME
/go"
>>
/root/.bashrc
\
&&
echo
"export PATH=
$PATH
:/usr/local/go/bin"
>>
/root/.bashrc
FROM
centos:7.3.1611
RUN
yum
-y
install
wget
&&
\
yum
-y
install
epel-release
&&
yum
-y
install
patchelf
&&
\
yum
-y
install
gcc make python-devel
&&
\
yum clean all
&&
\
curl https://bootstrap.pypa.io/get-pip.py
-o
get-pip.py
&&
\
python get-pip.py
&&
rm
get-pip.py
tools/Dockerfile.devel
0 → 100644
浏览文件 @
f35557de
FROM centos:7.3.1611
RUN yum -y install wget >/dev/null \
&& yum -y install gcc gcc-c++ make glibc-static which >/dev/null \
&& yum -y install git openssl-devel curl-devel bzip2-devel python-devel >/dev/null \
&& wget https://cmake.org/files/v3.2/cmake-3.2.0-Linux-x86_64.tar.gz >/dev/null \
&& tar xzf cmake-3.2.0-Linux-x86_64.tar.gz \
&& mv cmake-3.2.0-Linux-x86_64 /usr/local/cmake3.2.0 \
&& echo 'export PATH=/usr/local/cmake3.2.0/bin:$PATH' >> /root/.bashrc \
&& rm cmake-3.2.0-Linux-x86_64.tar.gz \
&& wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz >/dev/null \
&& tar xzf go1.14.linux-amd64.tar.gz \
&& mv go /usr/local/go \
&& echo 'export GOROOT=/usr/local/go' >> /root/.bashrc \
&& echo 'export PATH=/usr/local/go/bin:$PATH' >> /root/.bashrc \
&& rm go1.14.linux-amd64.tar.gz \
&& yum -y install python-devel sqlite-devel >/dev/null \
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py >/dev/null \
&& python get-pip.py >/dev/null \
&& pip install google protobuf setuptools wheel flask >/dev/null \
&& rm get-pip.py \
&& yum -y install epel-release && yum -y install patchelf \
&& yum clean all
tools/Dockerfile.gpu
浏览文件 @
f35557de
FROM paddlepaddle/paddle_manylinux_devel:cuda9.0_cudnn7
RUN yum -y install git openssl-devel curl-devel bzip2-devel \
&& wget https://dl.google.com/go/go1.12.12.linux-amd64.tar.gz \
&& tar -xzvf go1.12.12.linux-amd64.tar.gz \
&& rm -rf /usr/local/go \
&& mv go /usr/local/go \
&& rm go1.12.12.linux-amd64.tar.gz \
&& echo "GOROOT=/usr/local/go" >> /root/.bashrc \
&& echo "GOPATH=$HOME/go" >> /root/.bashrc \
&& echo "PATH=$PATH:$GOROOT/bin" >> /root/.bashrc
FROM nvidia/cuda:9.0-cudnn7-runtime-centos7
RUN yum -y install wget && \
yum -y install epel-release && yum -y install patchelf && \
yum -y install gcc make python-devel && \
yum -y install libSM-1.2.2-2.el7.x86_64 --setopt=protected_multilib=false && \
yum -y install libXrender-0.9.10-1.el7.x86_64 --setopt=protected_multilib=false && \
yum -y install libXext-1.3.3-3.el7.x86_64 --setopt=protected_multilib=false && \
yum clean all && \
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python get-pip.py && rm get-pip.py && \
ln -s /usr/local/cuda-9.0/lib64/libcublas.so.9.0 /usr/local/cuda-9.0/lib64/libcublas.so && \
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64':$LD_LIBRARY_PATH >> /root/.bashrc && \
ln -s /usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn.so.7 /usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn.so && \
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.0/targets/x86_64-linux/lib:$LD_LIBRARY_PATH' >> /root/.bashrc
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录