问题描述
我目前正试图让我的图像处理程序在Ubuntu上运行(来自Windows)。
我已经成功构建并链接了OpenCV和Boost库以与我的cpp程序一起使用,但是 我还没有找到任何有关在Ubuntu 20.04上设置Onnx Runtime C ++的说明。 ,除了将以下命令与NuGet程序包管理器一起用于特定的Visual Studio项目:
Install-Package microsoft.ml.OnnxRuntime -Version 1.4.0
在Windows上,我只需要使用NuGet包管理器来下载给定Visual Studio项目的库。在Ubuntu上使用NuGet似乎可以做到这一点,但我想知道是否可以像boost和OpenCV那样更“手动”地进行构建和安装。谢谢!
解决方法
对于默认的CPU版本,您可以下载tgz文件here。
对于其他不能以tgz或NuGet形式提供的ONNX运行时版本(例如TensorRT),您可以在本地进行构建:
./build.sh --cudnn_home <path to cuDNN e.g. /usr/lib/x86_64-linux-gnu/> --cuda_home <path to folder for CUDA e.g. /usr/local/cuda> --use_tensorrt --tensorrt_home <path to TensorRT home>
更多说明,请访问Building ONNX Runtime
,在 Linux 上安装 NuGet Onnxruntime 版本
在 Ubuntu 20.04 上测试
对于可通过 NuGet 获得的较新版本的 onnxruntime,我采用了以下工作流程:下载该版本(此处为 1.7.0,但您可以相应地更新链接),并将其安装到 {{1 }}。对于全局(系统范围)安装,您可以将文件放在 ~/.local/
下的相应文件夹中。
/usr/local/
Cmake
现在,如果您希望能够从您的 Cmake 包中 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/
,我建议您将我自己创建的 onnx cmake 文件放在 find_package(onnxruntime)
中。文件是:
~/.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