openvinotoolkit / openvino_notebooks

📚 Jupyter notebook tutorials for OpenVINO™
Apache License 2.0
2.42k stars 812 forks source link

NPU support on yolov8 #2398

Open weberwcwei opened 1 month ago

weberwcwei commented 1 month ago

Describe the bug When attempting to compile the YOLOv8 model using the NPU, a RuntimeError occurs.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[8], line 7
      5 model = core.read_model(model_path)
      6 model.reshape([1, 3, 640, 640])
----> 7 compiled_model = core.compile_model(model, "NPU")

File c:\Users\Weber\Desktop\.conda\Lib\site-packages\openvino\runtime\ie_api.py:543, in Core.compile_model(self, model, device_name, config, weights)
    538     if device_name is None:
    539         return CompiledModel(
    540             super().compile_model(model, {} if config is None else config),
    541         )
    542     return CompiledModel(
--> 543         super().compile_model(model, device_name, {} if config is None else config),
    544     )
    545 else:
    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

Sample code

from pathlib import Path
import openvino as ov

models_dir = Path("./model_zoo")
DET_MODEL_NAME = "yolov8n"

model_path = models_dir / f"{DET_MODEL_NAME}_openvino_model/{DET_MODEL_NAME}.xml"
core = ov.Core()
model = core.read_model(model_path)
model.reshape([1, 3, 640, 640])
compiled_model = core.compile_model(model, "NPU")

Installation instructions (Please mark the checkbox) [X] I followed the installation guide at https://github.com/openvinotoolkit/openvino_notebooks#-installation-guide to install the notebooks.

Additional context NPU driver version: 32.0.100.2714

brmarkus commented 1 month ago

Can you provide details about the platform you are using, which HW you are running on? Which operating system do you use? Which version of OpenVINO do you use?

When using the current version of the notebook "http://localhost:8888/lab/tree/yolov8-optimization/yolov8-object-detection.ipynb" then I still see the problem of failing compilation with like [...] from unsupported opset: opset14, as mentioned in other issues, for which workarounds exist (see e.g. "https://github.com/openvinotoolkit/openvino_notebooks/issues/2167#issuecomment-2269827840").

weberwcwei commented 1 month ago

Hi @brmarkus ,

Here are the platform details:

Follow your mention, I tried changing the maxpool operation from opset14 to opset8 in xml, and the model compiled successfully.

I also find a similar open issue in here (https://github.com/openvinotoolkit/openvino/issues/26510).

brmarkus commented 1 month ago

I think the dev-team is still working on this, please expect follow-up questions from them, like asking you to try a newer version or patches.