microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.7k stars 2.93k forks source link

failure using ONNX Runtime QNNExecutionProvider on Snapdragon® X Elite NPU #22617

Open tuquanrong opened 2 weeks ago

tuquanrong commented 2 weeks ago

Describe the issue

I followed this documentation, but ended up with an error https://onnxruntime.ai/docs/execution-providers/QNN-ExecutionProvider.html#configuration-options

Error Information:Specified provider 'QNNExecutionProvider is not in available provider name.Avaliable prodivers: 'AzureExecutionProvider,CPUExecutionProvider'

Environment:

Device: Snapdragon® X Elite (X1E80100 - Qualcomm®) ONNX Runtime Version: onnxruntime-qnn 1.19.0 Model: Yolov11 Model Format: Optimized and quantized ONNX model (model_optimized_quantized.onnx) Execution Provider: QNNExecutionProvider Python Version: Python 3.10.11 OS: Windows 11 Code Snippet:

To reproduce

import onnxruntime import numpy as np options = onnxruntime.SessionOptions() options.add_session_config_entry("session.disable_cpu_ep_fallback", "1") session = onnxruntime.InferenceSession("model.qdq.onnx", sess_options=options, providers=["QNNExecutionProvider"], provider_options=[{"backend_path": "QnnHtp.dll"}])

Urgency

No response

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.19.2

Execution Provider

Other / Unknown

ashumish-QCOM commented 2 weeks ago

Hi @tuquanrong

I noticed you're encountering an issue with the QNNExecutionProvider on the Snapdragon® X Elite NPU. The error message indicates that the specified provider 'QNNExecutionProvider' is not available. Here are a few steps that might help resolve this issue:

  1. Ensure FP16 Precision: When using the HTP backend, the model should be in FP16 precision. You can achieve this in two ways:

    • Provider Options: Specify the FP16 precision directly in the provider_options when creating the InferenceSession.
    • Model Conversion: Convert your model to FP16 precision using the onnxconverter_common package before passing it to the inference session.
  2. Check Installation: Ensure that the QNNExecutionProvider is correctly installed and configured.

  3. Update ONNX Runtime: Make sure you are using the latest version of ONNX Runtime.

I hope this helps!

HectorSVC commented 2 weeks ago

Please enable verbose log to get more details. Most likely environment setup issue. There's backend setup error if that's the case. Also what's your python environment, is it x64 or arm64 environment?