我目前正试图让我的图像处理程序在Ubuntu上工作(来自windows)。
我已经成功地构建并链接了OpenCV和Boost库来使用我的cpp程序,但是还没有找到任何关于在Ubuntu20.04上设置Onnx C++的说明,除了对特定的Visual项目使用NuGet包管理器使用以下命令以外:
Install-Package Microsoft.ML.OnnxRuntime -Version 1.4.0
在Windows上,我只需要使用NuGet包管理器来下载给定visual项目的库。在Ubuntu上使用NuGet似乎可以做到这一点,但我想知道我是否可以更“手动”地完成它,比如boost和OpenCV的构建和安装。谢谢!
发布于 2020-08-14 23:05:56
发布于 2021-03-05 14:41:30
在Linux上安装NuGet on运行时发行版
在Ubuntu 20.04上测试
对于通过NuGet提供的into运行时的新版本,我采用了以下工作流程:下载发行版(这里是1.7.0,但您可以相应地更新链接),并将其安装到~/.local/
中。对于全局(系统范围)安装,您可以将文件放在/usr/local/
下的相应文件夹中。
mkdir /tmp/onnxInstall
cd /tmp/onnxInstall
wget -O onnx_archive.nupkg https://www.nuget.org/api/v2/package/Microsoft.ML.OnnxRuntime/1.7.0
unzip onnx_archive.nupkg
cp runtimes/linux-x64/native/libonnxruntime.so ~/.local/lib/
cp -r build/native/include/ ~/.local/include/onnxruntime/
Cmake
现在,如果您希望能够从您的Cmake包中find_package(onnxruntime)
,我建议您将我自己创建的onnx文件放在~/.local/share/cmake/onnxruntime
中。这些档案是:
cat ~/.local/share/cmake/onnxruntime/onnxruntimeVersion.cmake
# Custom cmake version file by jcarius
set(PACKAGE_VERSION "1.7.0")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
cat ~/.local/share/cmake/onnxruntime/onnxruntimeConfig.cmake
# Custom cmake config file by jcarius to enable find_package(onnxruntime) without modifying LIBRARY_PATH and LD_LIBRARY_PATH
#
# This will define the following variables:
# onnxruntime_FOUND -- True if the system has the onnxruntime library
# onnxruntime_INCLUDE_DIRS -- The include directories for onnxruntime
# onnxruntime_LIBRARIES -- Libraries to link against
# onnxruntime_CXX_FLAGS -- Additional (required) compiler flags
include(FindPackageHandleStandardArgs)
# Assume we are in <install-prefix>/share/cmake/onnxruntime/onnxruntimeConfig.cmake
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(onnxruntime_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
set(onnxruntime_INCLUDE_DIRS ${onnxruntime_INSTALL_PREFIX}/include)
set(onnxruntime_LIBRARIES onnxruntime)
set(onnxruntime_CXX_FLAGS "") # no flags needed
find_library(onnxruntime_LIBRARY onnxruntime
PATHS "${onnxruntime_INSTALL_PREFIX}/lib"
)
add_library(onnxruntime SHARED IMPORTED)
set_property(TARGET onnxruntime PROPERTY IMPORTED_LOCATION "${onnxruntime_LIBRARY}")
set_property(TARGET onnxruntime PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIRS}")
set_property(TARGET onnxruntime PROPERTY INTERFACE_COMPILE_OPTIONS "${onnxruntime_CXX_FLAGS}")
find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_LIBRARY onnxruntime_INCLUDE_DIRS)
https://stackoverflow.com/questions/63420533
复制相似问题