Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add deploy for UIE#2307

Merged
linjieccc merged 17 commits into
PaddlePaddle:developfrom
linjieccc:deploy_uie
May 31, 2022
Merged

Add deploy for UIE#2307
linjieccc merged 17 commits into
PaddlePaddle:developfrom
linjieccc:deploy_uie

Conversation

@linjieccc

Copy link
Copy Markdown
Contributor

PR types

New features

PR changes

APIs

Description

Add deploy for UIE

@wawltor wawltor self-requested a review May 25, 2022 07:17
@wawltor wawltor self-assigned this May 25, 2022

@ZeyuChen ZeyuChen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

体现下切换schema不需要更换predictor的代码吧 不然会以为一个schema一个predictor。另外就taskflow的版本应该可以做到内置高性能predictor

args.schema = schema
predictor = UIEPredictor(args)

outputs = predictor.predict(text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这样利于中途更换schema预测别的文本吗?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

新增Taskflow内置高性能predictor的版本,部署脚本加上了predictor切换schema的代码示例

@linjieccc linjieccc marked this pull request as ready for review May 29, 2022 14:08
Comment thread paddlenlp/taskflow/task.py Outdated
self._custom_model = False
self._param_updated = False
self._num_threads = self.kwargs[
'num_threads'] if 'num_threads' in self.kwargs else cpu_count()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这块是一定要把CPU打满了,打满最终的机器有啥影响吗?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

如沟通,已修改为当前CPU的实际物理核数

import paddle2onnx
from onnxconverter_common import float16
self._predictor_type = 'onnxruntime'
except:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里的提示安装有个问题,onnxruntime和onnxruntime-gpu版本如何解决冲突?同时onnxruntime-gpu是不是通过conda安装更好

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thx

self._static_params_file)
self._prepare_static_mode()
else:
self._prepare_onnx_mode()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里是不是这个开关目前只是对UIE打卡了,因为不是所有的模型都能paddle2onnx吧

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

目前onnxruntime的predictor只对UIE有效,其他任务目前默认走PaddleInference

Comment thread model_zoo/uie/README.md Outdated
#### 可配置参数说明

* `num_threads`:配置CPU的线程数,默认为CPU的最大线程数。
* `infer_precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,如果选择`fp16`,请先确保机器正确安装NVIDIA相关驱动和基础软件,确保CUDA>=11.2,CuDNN>=8.2,初次使用需按照提示安装相关依赖。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这块有个疑问,如果是用conda安装飞桨cuda 11.2的版本的paddle的时候,这个时候适配的cudnn的版本是啥版本了?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

已修改为conda安装paddle对应的cudnn版本,已验证可以正常使用

@@ -0,0 +1,84 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2021->2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done,thx

import paddle
import paddle2onnx
import onnxruntime as ort
from multiprocessing import cpu_count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这块的import提前

Comment thread model_zoo/uie/README.md Outdated

#### 可配置参数说明

* `num_threads`:配置CPU的线程数,默认为CPU的逻辑核数/2。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

就直接写CPU的物理核数即可。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

如沟通,已移除num_threads,默认使用最优配置

Comment thread model_zoo/uie/README.md Outdated
#### 可配置参数说明

* `num_threads`:配置CPU的线程数,默认为CPU的逻辑核数/2。
* `infer_precision`:选择模型精度,默认为`fp32`,可选有`fp16`和`fp32`。`fp16`推理速度更快,如果选择`fp16`,请先确保机器正确安装NVIDIA相关驱动和基础软件,确保CUDA>=11.2,CuDNN>=8.1.1,初次使用需按照提示安装相关依赖。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FP16更重要的要硬件支持,而不只是CUDA cuDNN。

CuDNN -> cuDNN,要保持和原NV标准写法一致

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/device/cuda/get_device_capability_cn.html

内部使用get_device_capability这个api获取gpu架构信息,自动识别是否支持fp16然后自动开启,不需要暴露给用户。

包括num_threads这些taskflow都不要暴露,自动选择最优的配置来做。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thx
已补充硬件支持相关说明

@wawltor wawltor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@linjieccc linjieccc merged commit 8c86f33 into PaddlePaddle:develop May 31, 2022
@linjieccc linjieccc deleted the deploy_uie branch May 31, 2022 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants