Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pipelines/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,11 @@ rm -rf faiss_document_store.db
```
export CUDA_VISIBLE_DEVICES=""
```

#### 运行streamlit前端程序出现错误:`AttributeError: module 'click' has no attribute 'get_os_args'`

click版本过高导致:

```
pip install click==8.0
```
4 changes: 3 additions & 1 deletion pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ GPU 镜像下载大概耗时 15 分钟左右,容器启动成功后,等待1
| CPU | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0 | Linux |
| CPU | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0.windows.darwin | Windows&Macos |
| CUDA10.2 + cuDNN 7 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | registry.baidubce.com/paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |

如果您的机器不在中国大陆地区,我们推荐您使用DockerHub的镜像:

| 环境 | 镜像 Tag | 运行平台 |
| :--------------------------: | :-------------------------------: | :-------------: |
| CPU | paddlepaddle/paddlenlp:2.4.0 | Linux |
| CPU | paddlepaddle/paddlenlp:2.4.0.windows.darwin | Windows&Macos |
| CUDA10.2 + cuDNN 7 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA10.2 + cuDNN 7 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda10.2-cudnn7 | Linux |
| CUDA11.2 + cuDNN 8 | paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 | Linux |

对于智能问答应用,请参考Docker文档[docker文档](./docker/README.md),只需做少量的修改,就可以完成智能问答应用的部署。

Expand Down
63 changes: 63 additions & 0 deletions pipelines/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,66 @@ docker-compose -f docker-compose-gpu.yml stop
docker logs pip02
```
构建过程一般会持续3分钟左右,然后cpu版本启动等待1分钟左右,然后您就可以打开浏览器访问 http://127.0.0.1:8502 地址体验语义检索系统服务了。

## 3. Docker编译一个定制化Cuda版本的Pipelines的镜像

Docker编译一个定制化Cuda版本的Pipelines的镜像流程分2步,第一步是构建一个基础镜像,第二步是构建一键启动镜像。第一步构建的镜像是一个可用的状态,但是启动后,需要进入容器,然后手工启动服务,然后需要把运行命令打包到镜像中,使得Docker启动的时候能够自动启动Pipelines的服务。

### 3.1 基础镜像

以CUDA 11.2镜像为例,编译一个镜像流程如下,首先构建一个包含Pipelines环境的镜像:

```
nvidia-docker run --name pipelines --net host --shm-size 4g -it registry.baidubce.com/paddlepaddle/paddle:2.3.2-gpu-cuda11.2-cudnn8 /bin/bash
git clone https://github.com/PaddlePaddle/PaddleNLP.git
cd PaddleNLP/pipelines/
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
python setup.py install
apt-get install lsof
```
镜像构建完成可以使用`Ctrl+P+Q`组合键跳出容器。

在第一步构建镜像的过程中,如果是Cuda的其他版本,则需要在[官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/docker/linux-docker.html)上查找是否有对应的CUDA版本的Docker,如果没有,则需要自己手工构建一个该CUDA版本的Docker,然后安装对应CUDA版本的PaddlePaddle,然后继续执行上面的流程。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cuda 写法统一 CUDA

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改


### 3.2 一键启动镜像

到了上一步就构建了一个可用的Pipelines镜像了,但是这个镜像还没有一键启动功能,即需要进入容器手动启动后台和前端。这里进一步打包镜像,把启动运行的命令也打包到镜像中,执行过程如下:

```
docker commit pipelines pipelines:1.0-gpu-cuda11.2-cudnn8
docker tag pipelines:1.0-gpu-cuda11.2-cudnn8 paddlepaddle/paddlenlp:pipelines-1.0-gpu-cuda11.2-cudnn8
# 在容器外下载一份PaddleNLP代码
git clone https://github.com/PaddlePaddle/PaddleNLP.git
cd PaddleNLP/pipelines/docker
```
修改`Dockerfile-GPU`文件,更换基础镜像,并添加一键运行命令:

```
FROM paddlepaddle/paddlenlp:pipelines-1.0-gpu-cuda11.2-cudnn8
# 使得Docker容器启动start.sh,并且保持运行
ENTRYPOINT /root/start.sh && tail -f /dev/null
```
然后执行:

```
# Dockerfile-GPU 包含一键启动的命令
docker build --tag=paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8 . -f Dockerfile-GPU
```

这样就构建了一键启动的Docker镜像。

### 3.3 启动镜像

一键启动的Docker构建完成以后就可以使用下面的命令启动:

```
nvidia-docker run -d --name paddlenlp_pipelines_gpu --net host -ti paddlepaddle/paddlenlp:2.4.0-gpu-cuda11.2-cudnn8
# 查看运行日志
sudo docker logs paddlenlp_pipelines_gpu
# 进入容器命令
sudo docker exec -it paddlenlp_pipelines_gpu bash
# 查看后台端口状态
lsof -i:8891
# 查看前端端口状态
lsof -i:8502
```
1 change: 1 addition & 0 deletions pipelines/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ opencv-contrib-python-headless
python-multipart
htbuilder@git+https://github.com/tvst/htbuilder.git
st-annotated-text
click==8.0
streamlit==1.9.0
fastapi
uvicorn
Expand Down