Skip to content

[Build] Undefined symbol Ort::Device::NPU when building with OpenVINO EP #26283

@toms-g2

Description

@toms-g2

Describe the issue

Building OpenVINO 2025.3.0 and ONNX Runtime 1.23.1 with OpenVINO EP on Fedora 42 Linux with GCC 14, configured as HETERO:GPU,CPU, I get a library load error with undefined symbol that demangles to Ort::Device::NPU at runtime from the OpenVINO EP shared library.

My quick-n-dirty incorrect but effective fix:

diff --git a/onnxruntime/core/providers/openvino/openvino_execution_provider.cc b/onnxruntime/core/providers/openvino/openvino_execution_provider.cc
index a0fa885cb..de0d0b791 100644
--- a/onnxruntime/core/providers/openvino/openvino_execution_provider.cc
+++ b/onnxruntime/core/providers/openvino/openvino_execution_provider.cc
@@ -310,3 +310,5 @@ const InlinedVector<const Node*> OpenVINOExecutionProvider::GetEpContextNodes()

 }  // namespace openvino_ep
 }  // namespace onnxruntime
+
+const OrtDevice::DeviceType OrtDevice::NPU;

With that in place, I can build, run, and perform GPU-accelerated inference. Without it, the OpenVINO EP won't load at all.

Urgency

I am currently patching the source and the resulting build works, so the urgency is low for me.

Target platform

Linux in this instance, also Windows

Build script

ExternalProject_Add(OpenVINO
…
    CMAKE_ARGS
…
        -DENABLE_CPPLINT=OFF
        -DENABLE_CPPLINT_REPORT=OFF
        -DENABLE_DEBUG_CAPS=ON
        -DENABLE_HETERO=ON
        -DENABLE_INTEL_CPU=ON
        -DENABLE_INTEL_GPU=ON
        -DENABLE_INTEL_NPU=OFF
        -DENABLE_PACKAGING=OFF
        -DENABLE_SAMPLES=OFF
…
    )
set(OPENVINO_HARDWARE_OPTION "HETERO:GPU,CPU")
…
    set(onnxruntime_openvino_args --use_openvino ${OPENVINO_HARDWARE_OPTION})
    set(onnxruntime_openvino_cmake_defines
        OpenVINO_DIR='<INSTALL_DIR>/runtime/cmake'
    )
…
set(ORT_CONFIGURE_ARGS
    --update
    --skip_submodule_sync
    --build_dir "<BINARY_DIR>"
    --config ${CMAKE_BUILD_TYPE}
    --build_shared_lib
    --use_cuda
    --nvcc_threads 1
    ${onnxruntime_openvino_args}
    --cuda_home ${CUDA_HOME}
    --cudnn_home ${CUDNN_HOME}
    --cmake_extra_defines
        CMAKE_INSTALL_PREFIX=<INSTALL_DIR>
        CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'
        CMAKE_CUDA_ARCHITECTURES='${onnxruntime_cuda_architectures}'
        CMAKE_CXX_STANDARD=20
        CMAKE_C_COMPILER='${CMAKE_C_COMPILER}'
        CMAKE_CXX_COMPILER='${CMAKE_CXX_COMPILER}'
        onnxruntime_BUILD_SHARED_LIB=ON
        ${onnxruntime_openvino_cmake_defines}
        ${onnxruntime_build_unit_tests}
    --cmake_generator ${CMAKE_GENERATOR}
    --compile_no_warning_as_error
)
…
set(ORT_BUILD_ARGS
    --build
    --build_shared_lib
    --build_dir "<BINARY_DIR>"
    --config ${CMAKE_BUILD_TYPE}
    --cmake_generator ${CMAKE_GENERATOR}
    --parallel ${CMAKE_BUILD_PARALLEL_LEVEL}
    --compile_no_warning_as_error
    --target install
)
…
ExternalProject_Add(ONNXRuntime
…
    CONFIGURE_COMMAND ${Python3_EXECUTABLE} "<SOURCE_DIR>/tools/ci_build/build.py" ${ORT_CONFIGURE_ARGS}
    BUILD_COMMAND ${Python3_EXECUTABLE} "<SOURCE_DIR>/tools/ci_build/build.py" ${ORT_BUILD_ARGS}
…
    )

Error / output

Sorry, I lost the exact output in the shuffle, having stepped through the "fix" and rebuilt successfully. I'm just looping back around to file this issue. But I inspected the library itself and the symbol was in fact undefined even though every dependency was resolving per ldd.

Visual Studio Version

2022

GCC / Compiler Version

14.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildbuild issues; typically submitted using templateep:OpenVINOissues related to OpenVINO execution provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions