Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自行编译的fastdeploy无法使用gpu进行推理 #2533

Open
tammy-na opened this issue Oct 11, 2024 · 1 comment
Open

自行编译的fastdeploy无法使用gpu进行推理 #2533

tammy-na opened this issue Oct 11, 2024 · 1 comment
Assignees

Comments

@tammy-na
Copy link

环境

  • 【编译命令】自行编译的FastDeploy,(参数命令):

cd FastDeploy/python
export ENABLE_ORT_BACKEND=ON
export ENABLE_PADDLE_BACKEND=ON
export ENABLE_OPENVINO_BACKEND=ON
export ENABLE_VISION=ON
export ENABLE_TEXT=ON
export ENABLE_TRT_BACKEND=ON
export WITH_GPU=ON
export TRT_DIRECTORY=/usr/local/TensorRT-8.5.2.2
export CUDA_DIRECTORY=/usr/local/cuda-11.7
export OPENCV_DIRECTORY=/usr/lib/x86_64-linux-gnu/cmake/opencv4

python setup.py build
python setup.py bdist_wheel

  • 【系统平台】: Linux x64(Ubuntu 20.04.1)
  • 【硬件】: Nvidia GPU 3060, CUDA 11.7 CUDNN 8.6.0
  • 【编译语言】:Python3.8

问题日志及出现问题的操作流程

cd FastDeploy/examples/vision/ocr/PP-OCR/cpu-gpu/python
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device gpu --backend paddle
[INFO] fastdeploy/runtime/backends/paddle/paddle_backend.cc(29)::BuildOption Will inference_precision float32
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::GPU.
[INFO] fastdeploy/runtime/backends/paddle/paddle_backend.cc(29)::BuildOption Will inference_precision float32
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::GPU.
[INFO] fastdeploy/runtime/backends/paddle/paddle_backend.cc(29)::BuildOption Will inference_precision float32
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::GPU.
free(): invalid size
已放弃 (核心已转储)
问题总结:当--device gpu 时会中断推理,当--device cpu时不存在问题:
python infer.py --det_model ch_PP-OCRv3_det_infer --cls_model ch_ppocr_mobile_v2.0_cls_infer --rec_model ch_PP-OCRv3_rec_infer --rec_label_file ppocr_keys_v1.txt --image 12.jpg --device cpu --backend paddle
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::CPU.
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::CPU.
[INFO] fastdeploy/runtime/runtime.cc(286)::CreatePaddleBackend Runtime initialized with Backend::PDINFER in Device::CPU.
det boxes: [[42,413],[483,391],[484,428],[43,450]]rec text: 上海斯格威铂尔大酒店 rec score:0.980085 cls label: 0 cls score: 1.000000
det boxes: [[187,456],[399,448],[400,480],[188,488]]rec text: 打浦路15号 rec score:0.964993 cls label: 0 cls score: 1.000000
det boxes: [[23,507],[513,488],[515,529],[24,548]]rec text: 绿洲仕格维花园公寓 rec score:0.993727 cls label: 0 cls score: 1.000000
det boxes: [[74,553],[427,542],[428,571],[75,582]]rec text: 打浦路252935号 rec score:0.947723 cls label: 0 cls score: 1.000000

当我把自行编译的fastdeploy卸载之后安装:pip install fastdeploy-gpu-python==1.0.7 -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html,这时gpu和cpu都可以推理,我为什么非要重新编译fastdeploy是因为我想要添加如下内容到fastdeploy/vision/vision_pybind.cc文件中。
.def_readwrite("table_html", &vision::OCRResult::table_structure)
.def_readwrite("table_boxes", &vision::OCRResult::table_boxes)

@Jiang-Jia-Jun
Copy link
Collaborator

Linux吗,你可以试下使用Paddle官方的镜像来编译

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

No branches or pull requests

3 participants