PaddlePaddle / PaddlePaddle/FastDeploy

按教程部署完insightface后发现只能使用cpu

Open
#2,610 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
756
Avg merge
19h 28m
Merged PRs (30d)
4

Description

使用文档

首先是根据这个文档InsightFace Python部署示例,根据其环境要求导航到FastDeploy RKNPU2 导航文档,

我的环境

python是3.8
rknn版本是2.3.0
Image

使用情况

按照教程指令编译成功

git clone https://github.com/PaddlePaddle/FastDeploy.git
cd FastDeploy

# 如果您使用的是develop分支输入以下命令
git checkout develop

cd python
export ENABLE_ORT_BACKEND=ON
export ENABLE_RKNPU2_BACKEND=ON
export ENABLE_VISION=ON

# 请根据你的开发版的不同,选择RK3588和RK356X
export RKNN2_TARGET_SOC=RK3588

# 如果你的核心板的运行内存大于等于8G,我们建议您执行以下命令进行编译。
python3 setup.py build
# 值得注意的是,如果你的核心板的运行内存小于8G,我们建议您执行以下命令进行编译。
python3 setup.py build -j1

python3 setup.py bdist_wheel
cd dist
pip3 install fastdeploy_python-0.0.0-cp39-cp39-linux_aarch64.whl

部分编译参数如下

Image

安装fastdeploy_python后按照文档指令

#下载部署示例代码
git clone https://github.com/PaddlePaddle/FastDeploy.git
cd examples/vision/faceid/insightface/python/

#下载ArcFace模型文件和测试图片
wget https://bj.bcebos.com/paddlehub/fastdeploy/ms1mv3_arcface_r100.onnx
wget https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/face_demo.zip
unzip face_demo.zip

# CPU推理
python infer_arcface.py --model ms1mv3_arcface_r100.onnx \
                        --face face_0.jpg \
                        --face_positive face_1.jpg \
                        --face_negative face_2.jpg \
                        --device cpu
# GPU推理
python infer_arcface.py --model ms1mv3_arcface_r100.onnx \
                        --face face_0.jpg \
                        --face_positive face_1.jpg \
                        --face_negative face_2.jpg \
                        --device gpu

gpu版本会提示

/FastDeploy/examples/vision/faceid/insightface/python$ python infer_arcface.py --model ms1mv3_arcface_r100.onnx                         --face face_0.jpg                         --face_positive face_1.jpg                         --face_negative face_2.jpg                         --device gpu
WARNING:root:The installed fastdeploy-python package is not built with GPU, will force to use CPU. To use GPU, following the commands to install fastdeploy-gpu-python.
WARNING:root:    ================= Install GPU FastDeploy===============
WARNING:root:    python -m pip uninstall fastdeploy-python
WARNING:root:    python -m pip install fastdeploy-gpu-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
[INFO] fastdeploy/runtime/runtime.cc(326)::CreateOrtBackend	Runtime initialized with Backend::ORT in Device::CPU.
FaceRecognitionResult: [Dim(512), Min(-2.309219), Max(2.372197), Mean(0.016987)]
FaceRecognitionResult: [Dim(512), Min(-2.288257), Max(1.995103), Mean(-0.003400)]
FaceRecognitionResult: [Dim(512), Min(-3.243412), Max(3.875865), Mean(-0.030682)]
Cosine 01:  0.814384554852488
Cosine 02:  -0.059388045136689285
RuntimeOption(
  backend : Backend.ORT	
  cpu_thread_num : -1	
  device : Device.CPU	
  device_id : 0	
  external_stream : None	
  model_file : ms1mv3_arcface_r100.onnx	
  model_format : ModelFormat.ONNX	
  model_from_memory : False	
  openvino_option : <fastdeploy.libs.fastdeploy_main.OpenVINOBackendOption object at 0x7fa003bc30>	
  ort_option : <fastdeploy.libs.fastdeploy_main.OrtBackendOption object at 0x7fa0078530>	
  paddle_infer_option : <fastdeploy.libs.fastdeploy_main.PaddleBackendOption object at 0x7fa0078530>	
  paddle_lite_option : <fastdeploy.libs.fastdeploy_main.LiteBackendOption object at 0x7fa0078530>	
  params_file : 	
  poros_option : <fastdeploy.libs.fastdeploy_main.PorosBackendOption object at 0x7fa0078530>	
  trt_option : <fastdeploy.libs.fastdeploy_main.TrtBackendOption object at 0x7fa0078530>	
)

输入指令查看npu使用情况确实没变化

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/vision/faceid/insightface/rknpu2/python/README_CN.md and docs/cn/build_and_install/rknpu2.md, then inspect python/setup.py and examples/vision/faceid/insightface/python/infer_arcface.py. Reproduce the --device gpu invocation and compare it with the reported build configuration; done means the documented RKNPU2 path uses the NPU or the documentation clearly explains the required configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.