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

[CANN] When using onnxruntime-cann for inference, it failed to utilize the NPU for inference #22229

Open
Eviltuzki opened this issue Sep 26, 2024 · 3 comments
Labels
ep:CANN issues related to CANN EO

Comments

@Eviltuzki
Copy link

Describe the issue

I downloaded the Llama2-7b-onnx model from Hugging Face. Using the example code, it runs normally in both GPU and CPU environments (using CPUExecutionProvider and CUDAExecutionProvider).
However, when I replace the providers with CANNExecutionProvider and run it in the NPU environment, the following issues occur:

  1. FP16 cannot run and basically hangs.
  2. FP32 barely runs, but only uses 100+ MB of memory, and the CPU usage reaches over 6000%.

The providers I am using only include CANNExecutionProvider. From the observations, it seems that the NPU is not being used for inference, and instead, the CPU is being used (the inference time on the NPU is even longer than on the CPU).NPU usage is as shown in the image.

image

To reproduce

code same as:
https://huggingface.co/alpindale/Llama-2-7b-ONNX/tree/main
I just replace providers

    providers = [
        (
            "CANNExecutionProvider",
            {
                "device_id": 0,
                "arena_extend_strategy": "kNextPowerOfTwo",
                "op_select_impl_mode": "high_performance",
                "optypelist_for_implmode": "Gelu",
                "enable_cann_graph": True
            },
        )
    ]

Urgency

No response

Platform

Linux

OS Version

openEuler

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

onnxruntime-cann 1.18.0

ONNX Runtime API

Python

Architecture

ARM64

Execution Provider

Other / Unknown

Execution Provider Library Version

Ascend-cann-toolkit_8.0.RC2

@github-actions github-actions bot added the ep:CANN issues related to CANN EO label Sep 26, 2024
@Eviltuzki
Copy link
Author

Supplement:
I have already tried manually compiling version 1.19.2 of onnxruntime-cann, same as 1.18.0

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Oct 26, 2024
@lucien-ye
Copy link

Any progress? I have the same problem,when add profile to session,it shows that all operations are running on cpu.

@github-actions github-actions bot removed the stale issues that have not been addressed in a while; categorized by a bot label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CANN issues related to CANN EO
Projects
None yet
Development

No branches or pull requests

2 participants