Closed song121982 closed 2 years ago
@song121982 量化模型导出后,在GPU上预测请使用TensorRT,设置run_mode='trt_int8'即可。(需要安装带有TensroRT的Paddle)具体可以查看文档:https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.4/deploy/TENSOR_RT.md
@yghstill 以前的量化导出模型在不使用‘run_mode='trt_int8'’指令的情况下,在没有tensorRT的设备上也是可以预测的啊,只不过没有加速而已,这次的导出模型不知道为什么一点效果都没有。
@yghstill 我又在https://www.paddlepaddle.org.cn/inference/v2.2/user_guides/download_lib.html#windows重新下载名为cuda11.2_cudnn8.1_avx_mkl-trt8.0.1.6
的python预测库,也完成了tensorRT下lib目录的环境变量添加。
pip install -r requirements.txt
python setup.py install
都执行完成,但在框架测试过程中报错:
python ppdet/modeling/tests/test_architectures.py
PS E:\syg\PaddleDetection-release-2.3> python ppdet/modeling/tests/test_architectures.py
WARNING: Logging before InitGoogleLogging() is written to STDERR
W0402 10:33:58.146404 37340 tensorrt.cc:56] You are using Paddle compiled with TensorRT, but TensorRT dynamic library is not found. Ignore this if TensorRT is not needed.
The TensorRT that Paddle depends on is not configured correctly.
Suggestions:
1. Check if the TensorRT is installed correctly and its version is matched with paddlepaddle you installed.
2. Configure environment variables as follows:
- Linux: set LD_LIBRARY_PATH by `export LD_LIBRARY_PATH=...`
- Windows: set PATH by `set PATH=XXX;%PATH%`
- Mac: set DYLD_LIBRARY_PATH by `export DYLD_LIBRARY_PATH=...`
E0402 10:33:58.146404 37340 port.h:50] Load symbol getPluginRegistry failed.
Error: Can not import avx core while this file exists: D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\fluid\core_avx.pyd
Traceback (most recent call last):
File "ppdet/modeling/tests/test_architectures.py", line 20, in <module>
import ppdet
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\__init__.py", line 15, in <module>
from . import (core, data, engine, modeling, model_zoo, optimizer, metrics,
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\__init__.py", line 15, in <module>
from . import source
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\source\__init__.py", line 15, in <module>
from . import coco
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\source\coco.py", line 18, in <module>
from .dataset import DetDataset
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\source\dataset.py", line 22, in <module>
from paddle.io import Dataset
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\__init__.py", line 25, in <module>
from .fluid import monkey_patch_variable
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\fluid\__init__.py", line 36, in <module>
from . import framework
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\fluid\framework.py", line 37, in <module>
from . import core
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\fluid\core.py", line 294, in <module>
raise e
File "D:\anaconda\envs\paddle-trt\lib\site-packages\paddle\fluid\core.py", line 256, in <module>
from .core_avx import *
ImportError: DLL load failed while importing core_avx: 动态链接库(DLL)初始化例程失败。
又在https://www.paddlepaddle.org.cn/documentation/docs/zh/install/Tables.html#whl-release下载的win-cuda11.2-cudnn8.2-mkl-vs2017-avx
的预测库同样卡在了python ppdet/modeling/tests/test_architectures.py
这次是另一种报错:
PS E:\syg\PaddleDetection-release-2.3> python ppdet/modeling/tests/test_architectures.py
D:\anaconda\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp, sys, os
Traceback (most recent call last):
File "ppdet/modeling/tests/test_architectures.py", line 20, in <module>
import ppdet
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\__init__.py", line 15, in <module>
from . import (core, data, engine, modeling, model_zoo, optimizer, metrics,
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\__init__.py", line 16, in <module>
from . import transform
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\transform\__init__.py", line 15, in <module>
from . import operators
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\data\transform\operators.py", line 44, in <module>
from ppdet.modeling import bbox_utils
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\__init__.py", line 25, in <module>
from . import architectures
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\architectures\__init__.py", line 21, in <module>
from . import deepsort
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\architectures\deepsort.py", line 22, in <module>
from ppdet.modeling.mot.utils import Detection, get_crops, scale_coords, clip_box
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\mot\__init__.py", line 15, in <module>
from . import matching
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\mot\matching\__init__.py", line 15, in <module>
from . import jde_matching
File "D:\anaconda\lib\site-packages\paddledet-2.3.0-py3.8.egg\ppdet\modeling\mot\matching\jde_matching.py", line 18, in <module>
import lap
File "D:\anaconda\lib\site-packages\lap\__init__.py", line 25, in <module>
from ._lapjv import (
File "__init__.pxd", line 199, in init lap._lapjv
ValueError: numpy.ndarray has the wrong size, try recompiling. Expected 80, got 88
numpy 版本的问题,安装 >=1.22.3
卸载numpy ,pip uninstall numpy -y 重新安装numpy , pip install numpy
@wangxinit 谢谢解答,和这个描述的是一个问题https://github.com/PaddlePaddle/PaddleDetection/issues/5626#issue-1195795538 我按照您说的重新安装了numpy,但是
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
paddlepaddle-gpu 2.2.2.post112 requires numpy<=1.19.3,>=1.13; python_version >= "3.5" and platform_system == "Windows", but you have numpy 1.22.3 which is incompatible.
导出模型的检测还是没有效果,我重新训练一下看看吧。
@wangxinit 谢谢解答,和这个描述的是一个问题#5626 (comment) 我按照您说的重新安装了numpy,但是
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. paddlepaddle-gpu 2.2.2.post112 requires numpy<=1.19.3,>=1.13; python_version >= "3.5" and platform_system == "Windows", but you have numpy 1.22.3 which is incompatible.
导出模型的检测还是没有效果,我重新训练一下看看吧。
我之前遇到过这个问题“ValueError: numpy.ndarray has the wrong size, try recompiling. Expected 80, got 88” 我装好paddlepaddle-gpu 再装PaddleDetection
最后卸载numpy 1.19 重新安装numpy1.22 也是会报错,但是PaddleDetection运行正常
@wangxinit 谢谢,这个能用了
“量化训练后的模型”导出后预测不出来结果 这个问题解决了吗,我也遇到这样的情况了。
环境:
win11 paddlepaddle-gpu 2.2.2.post112 paddledet 2.1.0 paddleslim 2.1.0
配置文件
以configs/yolov3/yolov3_r34_270e_coco.yml为基础,如下:
slim文件:
事故描述:
train结束得到的非部署模型可以正常得到预测结果,但是经过export_model之后的导出模型预测没有任何效果,也没报错
导出前预测: python tools/infer.py -c configs/yolov3/r34_vehicle.yml --infer_file=demo/03239.jpg -o weights=output/r34_vehicle6000_qat/model_final.pdparams 输出结果正常,能检测到物体
导出模型之后: python tools/export_model.py -c configs/yolov3/r34_vehicle.yml --slim_config configs/slim/quant/r34_vehicle6000_qat.yml -o weights=output/r34_vehicle6000_qat/model_final.pdparams
使用下面的指令使用导出模型预测,没有任何效果,没有任何预测框生成: python deploy/python/infer.py --model_dir=output_inference/r34_vehicle6000_qat --image_file=demo/03239.jpg --use_gpu=True
预测结果log: