Paddle python下paddleOcr 启用tensorrt出现问题

qij5mzcb  于 2021-11-30  发布在  Java
关注(0)|答案(9)|浏览(767)

paddle版本:2.1.1
GPU版centos
cudnn:7
gcc:8.2
cuda:10.1
问题:使用paddleOCR 做inference, python3.7运行后报错如下
C ++ traceback (most rerecent call last):
paddle infer::Predictor::Predictor (paddle::AnalysisConfig const&)
std: :unique pur paddle: Padereictor std: :default delete paddle: Padereictor ) paddle: CeleadelPredieior adle:halysisconfi
paddle: PaddleEngineKind) 2> (paddle: AnalysisConf const&)
paddle: :AnalysisPredictor::lni (std: :shared ptrKpaddle: :framework: :Scope> const&, std: :shared ptr<paddle:: framework:ProgramDesc const&)
paddle: :Analysi sPredictor: :PrepareProgram(std: :shared ptr(paddle: :framework: :ProgramDesc> const&)
paddle: :AnalysisPredictor: :0pt imizeInferenceProgram)
paddle:: inference: :analysis: :Analyzer: :RunAnalysis (paddle:: inference: :analysis: :Argumentx)
paddle: : inference: :analysis::lrAnalysisPass:: Runl mpl (paddle: :inference: :analysis: :Argument*)
paddle:: inference: :analysis::IRPassManager: :Apply (std: :unique ptrKpaddle: : framework::ir: :Graph, std: :default delete(paddle: :framework::ir::Graph> )
paddle: :framework::ir: :Pass: :Apply (paddle: :framework::ir: :Graph*) const
paddle:: inference: :analysis: : TensorRtSubgraphPass: :Apply Impl (paddle: : framework::ir: :Graph) const
10 paddle:: inference: :analysis::TensorRtSubgraphPas :CreateTensorRI0p (paddle: :framework::ir: :Node*, paddle:: framework::ir:Grapht std::vectorKstd::string std::allocatorstd::string > ) consutd::vectorKstd::string. std::allocatorstd::string >>*) const
11paddle::inference::tensorrt: :0pConverter: :ConvertBlockIoTRTEngine (paddle: :framework: :BlockDesc*, paddle: :framework: :Scope const&. std:vectorKstd::string. std: allocatorstd::string > > consstd: :uno.dered setKstd::string, std: ;hashtd:string >, std::equal_ toKstd::string >, std: :allocatorKstd::string ) ) const&, std::vectorKstd::string. std: allocatorstd::string ) ) const&, paddlnference:: tensorrt: : TensorRTEnginez)
12 paddle:: inference: : tensorrt::TensorTEngine: :FreezeNetwork )
3 paddle::plat form: : EnforceNotMet: :EnforceNotMet (paddle: :plat form; :ErrorSummary const&, char const*, int)
14 paddle: :plat form: :Ge tCurrentTraceBackStringabi:cxxl0

Error Message Summary:
FatalError: Build TensorRT cuda engine failed! Please recheck you conf igurations related to paddle-TensorRT.[Hint: infer engine_ should not be null.] (at /paddle/paddle/fluid/ inference/ tensorrt/engine cc:242)

查阅相关资料,有方案是paddle未加入trt依赖
尝试解决:https://paddle-inference.readthedocs.io/en/latest/user_guides/download_lib.html#python下载(未成功)
自己编译代trt的paddle,编译问题层出(未成功)
请问这个问题是由于什么情况引起的,如果是paddle未包含trt能提供cuda10.2_paddlev2.1_gcc8.2_cudnn7 centos的docker镜像或.whl包吗

sigwle7e

sigwle7e1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

mkshixfv

mkshixfv2#

您好,用默认方式安装的paddle目前无法直接支持tensorrt,可以直接安装支持tensorrt的paddle:https://paddle-wheel.bj.bcebos.com/with-trt/2.1.2/linux-gpu-cuda10.2-cudnn8.1-mkl-gcc8.2-trt6-avx/paddlepaddle_gpu-2.1.2-cp37-cp37m-linux_x86_64.whl

omqzjyyz

omqzjyyz4#

cuda10.1可以用这个:https://paddle-wheel.bj.bcebos.com/with-trt/2.1.2/linux-gpu-cuda10.1-cudnn7-mkl-gcc8.2-trt6-avx/paddlepaddle_gpu-2.1.2.post101-cp37-cp37m-linux_x86_64.whl ,以上tensorrt版paddle都来源于这个页面:https://www.paddlepaddle.org.cn/whl/stable/tensorrt.html ,可以按照自己的环境选择相应版本,你提供的下载链接是普通版,不支持tensorrt。

nfzehxib

nfzehxib5#

我按您给的网址装了,还是报原来的错误,Build TensorRT cuda engine failed!,能帮忙看看日日志吗,谢谢

t9eec4r0

t9eec4r06#

@sususu1 你用的是PaddleOCR哪个网络?是在create_predictor时报错的还是其他地方?
https://github.com/PaddlePaddle/PaddleOCR/blob/cadc04cf6cb599bb005be344010443bcfb65e82b/tools/infer/utility.py#L250

你可以关闭dynamic shape再试下,屏蔽这行代码:https://github.com/PaddlePaddle/PaddleOCR/blob/cadc04cf6cb599bb005be344010443bcfb65e82b/tools/infer/utility.py#L224

4xy9mtcn

4xy9mtcn8#

我用的是PaddleOCR-release-2.1好像没有这种动态代码,我换到docker运行后,发现det(DB)和cls都能跑起来,但是CRNN那块会报如下错误:
Traceback (most recent call. last):
File predictsys. py", line 227, in module>
recresult (r' /home/ workSpace/Paddle0CR- release 2. l/test data )
File "predictsys. py", line 224, in recresult
return main (args)
File " predictsys.py", line 148, in main
dt_ boxes, rec_ res = text sys (img)
File "predictsys. py", line 104, in_ call
rec_ res, elapse = self. text_ recognizer(img_ crop_ list)
File /home/workSpace/Paddle0CR- release -2. 1/tools/ infer/predict_ rec. py", line 235, in_ call
self. predictor. run0
ValueError: (Inval idArgument) Input shapes are inconsistent with the model. Expect [3, 32, 100] in model description, but got [3, 32, 163] in runtime. TRT 5 or lower version does not support dynamiinput shapes. Please check and modify your input shapes.
[Hint: Expected model_ input_ shape = runtime_ input_ shape = true, but received model_ input_ shape = runtime_ input_ shape:0 != true:l. ] (at /paddle/ paddle fluid operators/ tensorrt/ tensorrt_ engine_. h:76)

这里用的应该是静态图,但是我不知道这个shape是哪个地方的,中间输入我打印出来看到shape也不是【3,32,163】
然后,就是int8量化有好的教程吗,感谢帮忙解答

cs7cruho

cs7cruho9#

报错提示 你的输入数据shape是[3, 32, 163],但是期望的输入是 [3, 32, 100] ,所以可以检查下你的数据resize后的值;

如果你需要设置dynamic shape,确保安装的TRT是6.0版本以上的,设置dynamic shape的代码参考:https://github.com/PaddlePaddle/PaddleOCR/blob/cadc04cf6cb599bb005be344010443bcfb65e82b/tools/infer/utility.py#L224

相关问题