openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
7.14k stars 2.23k forks source link

[Bug]: Can not compile YOLOv8 on NPU #26961

Open weberwcwei opened 1 week ago

weberwcwei commented 1 week ago

OpenVINO Version

2024.4.0

Operating System

Windows System

Device used for inference

NPU

Framework

PyTorch

Model used

YOLOv8

Issue description

Error when compile on YOLOv8.

Step-by-step reproduction

from pathlib import Path
import openvino as ov

models_dir = Path("./model_zoo")
model_path = models_dir / f"yolov8n-pose_openvino_model/yolov8n-pose.xml"
core = ov.Core()
ov_model = core.read_model(model_path)
ov_config = {}
ov_model.reshape({0: [1, 3, 640, 640]})
compiled_model = core.compile_model(ov_model, "NPU", ov_config)

Relevant log output

RuntimeError                              Traceback (most recent call last)
Cell In[4], [line 6](vscode-notebook-cell:?execution_count=4&line=6)
      [4](vscode-notebook-cell:?execution_count=4&line=4) ov_config = {}
      [5](vscode-notebook-cell:?execution_count=4&line=5) ov_model.reshape({0: [1, 3, 640, 640]})
----> [6](vscode-notebook-cell:?execution_count=4&line=6) compiled_model = core.compile_model(ov_model, "NPU", ov_config)

File c:\Users\Weber\.conda\envs\intel_yolo\Lib\site-packages\openvino\runtime\ie_api.py:543, in Core.compile_model(self, model, device_name, config, weights)
    [538](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:538)     if device_name is None:
    [539](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:539)         return CompiledModel(
    [540](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:540)             super().compile_model(model, {} if config is None else config),
    [541](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:541)         )
    [542](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:542)     return CompiledModel(
--> [543](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:543)         super().compile_model(model, device_name, {} if config is None else config),
    [544](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:544)     )
    [545](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:545) else:
    [546](file:///C:/Users/Weber/.conda/envs/intel_yolo/Lib/site-packages/openvino/runtime/ie_api.py:546)     if device_name is None:

RuntimeError: Exception from src/inference/src/cpp/core.cpp:107:
Exception from src/inference/src/dev/plugin.cpp:53:
Exception from src/plugins/intel_npu/src/plugin/src/plugin.cpp:697:
Exception from src/plugins/intel_npu/src/plugin/src/compiled_model.cpp:62:
Exception from src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp:853:
L0 pfnCreate2 result: ZE_RESULT_ERROR_INVALID_ARGUMENT, code 0x78000004

Issue submission checklist

avitial commented 1 week ago

@weberwcwei the issue you observe may be the same as reported by other users, for current resolution on this issue please try the workaround shared in this comment. Hope this helps.

Ref. 148879