CMake can't find ONNX RUNTIME LIB when I try to compile onnx model which is converted from pytorch

140 Views Asked by At

I am trying to run the onnx model which is converted from pytorch in C++. but when I try to compile ONNX model in C++, It fails with the error shown below text.

CMake Error : The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files : ONNX_RUNTIME_LIB liked by target "ObjectDetectionInferende" in directory /hyeonseop/OD/test/onnx_od

I think CMake couldn't find the onnx runtime library.

my cmake code is

cmake_minimum_required(VERSION 3.25)
project(ObjectDetectionInference)

find_package(OpenCV REQUIRED)

find_path(ONNX_RUNTIME_SESSION_INCLUDE_DIRS onnxruntime_cxx_api.h HINTS "/hyeonseop/OD/onnxruntime-linux-x64-gpu-1.17.0/include")
find_library(ONNX_RUNTIME_LIB lib HINTS "/hyeonseop/OD/onnxruntime-linux-x64-gpu-1.17.0")

set(SOURCE_FILES main.cpp helper.cpp)

add_executable(ObjectDetectionInference ${SOURCE_FILES})

target_include_directories(ObjectDetectionInference PRIVATE ${ONNX_RUNTIME_SESSION_INCLUDE_DIRS}) # ${OpenCV_INCLUDE_DIRS}
target_link_libraries(ObjectDetectionInference PRIVATE ${ONNX_RUNTIME_LIB}) # ${OpenCV_LIBRARIES}

and My path is

root@4fe7a1a9f82d:/hyeonseop/OD/onnxruntime-linux-x64-gpu-1.17.0# ls

GIT_COMMIT_ID LICENSE Privacy.md README.md ThirdPartyNotices.txt VERSION_NUMBER include lib

root@4fe7a1a9f82d:/hyeonseop/OD/onnxruntime-linux-x64-gpu-1.17.0# pwd

/hyeonseop/OD/onnxruntime-linux-x64-gpu-1.17.0

I think there's no wrong. How can I solve it? Should I install onnx and onnx runtime again? nor It's occured because of dependencies or version?

0

There are 0 best solutions below