当前位置:首页 » 《我的小黑屋》 » 正文

【OnnxRuntime】在linux下编译并安装C++版本的onnx-runtime

0 人参与  2024年04月04日 13:50  分类 : 《我的小黑屋》  评论

点击全文阅读


目录

安装C++接口的onnx-runtime安装依赖项:下载源文件构建ONNX Runtime安装ONNX Runtime

安装C++接口的onnx-runtime

安装依赖项:

安装CMake:可以通过包管理器(如apt、yum等)安装CMake。

安装C++编译器:确保系统中已安装C++编译器,如GCC或Clang。

下载源文件

克隆ONNX Runtime的GitHub仓库,指定版本是为了适配python3.8:

git clone --branch v1.5.2 --recursive https://gitee.com/lee-zq/onnxruntime.git

构建ONNX Runtime

进入ONNX Runtime的源代码目录:
// 首先创建一个conda环境,因为./build.sh实际上调用的是./tools/cl_build/build.py

cd onnxruntimeconda create -n onnxruntime python=3.8./build.sh --skip_tests --config Release --build_shared_lib --parallel

注意,若配合cuda使用,命令行末尾应添加

-cuda_home /usr/local/cuda-11.3 --cudnn_home /usr/local/cuda-11.3

注意,编译前,确保机器装有linux环境:

sudo apt-get install build-essential

这将使用所有可用的CPU核心进行编译。如果希望使用指定数量的核心,可以将$(nproc)替换为所需的核心数量。

安装ONNX Runtime

运行以下命令进行安装:

cd /build/Linux/Releasesudo make install

通过按照上述步骤,您应该能够在Linux上成功安装ONNX Runtime。请注意,安装过程中可能需要根据您的系统和需求进行适当的调整。

Install the project...-- Install configuration: "Release"-- Installing: /usr/local/include/onnxruntime/core/common-- Installing: /usr/local/include/onnxruntime/core/common/code_location.h-- Installing: /usr/local/include/onnxruntime/core/common/common.h-- Installing: /usr/local/include/onnxruntime/core/common/const_pointer_container.h-- Installing: /usr/local/include/onnxruntime/core/common/eigen_common_wrapper.h-- Installing: /usr/local/include/onnxruntime/core/common/exceptions.h-- Installing: /usr/local/include/onnxruntime/core/common/logging-- Installing: /usr/local/include/onnxruntime/core/common/logging/capture.h-- Installing: /usr/local/include/onnxruntime/core/common/logging/isink.h-- Installing: /usr/local/include/onnxruntime/core/common/logging/logging.h-- Installing: /usr/local/include/onnxruntime/core/common/logging/macros.h-- Installing: /usr/local/include/onnxruntime/core/common/logging/severity.h-- Installing: /usr/local/include/onnxruntime/core/common/make_unique.h-- Installing: /usr/local/include/onnxruntime/core/common/optional.h-- Installing: /usr/local/include/onnxruntime/core/common/status.h-- Installing: /usr/local/include/onnxruntime/core/graph-- Installing: /usr/local/include/onnxruntime/core/graph/basic_types.h-- Installing: /usr/local/include/onnxruntime/core/graph/constants.h-- Installing: /usr/local/include/onnxruntime/core/graph/function.h-- Installing: /usr/local/include/onnxruntime/core/graph/graph.h-- Installing: /usr/local/include/onnxruntime/core/graph/graph_nodes.h-- Installing: /usr/local/include/onnxruntime/core/graph/graph_viewer.h-- Installing: /usr/local/include/onnxruntime/core/graph/indexed_sub_graph.h-- Installing: /usr/local/include/onnxruntime/core/graph/node_arg.h-- Installing: /usr/local/include/onnxruntime/core/graph/onnx_protobuf.h-- Installing: /usr/local/include/onnxruntime/core/graph/schema_registry.h-- Installing: /usr/local/include/onnxruntime/core/framework-- Installing: /usr/local/include/onnxruntime/core/framework/alloc_kind.h-- Installing: /usr/local/include/onnxruntime/core/framework/allocator.h-- Installing: /usr/local/include/onnxruntime/core/framework/customregistry.h-- Installing: /usr/local/include/onnxruntime/core/framework/data_types.h-- Installing: /usr/local/include/onnxruntime/core/framework/data_types_internal.h-- Installing: /usr/local/include/onnxruntime/core/framework/endian.h-- Installing: /usr/local/include/onnxruntime/core/framework/execution_provider.h-- Installing: /usr/local/include/onnxruntime/core/framework/fence.h-- Installing: /usr/local/include/onnxruntime/core/framework/framework_common.h-- Installing: /usr/local/include/onnxruntime/core/framework/func_api.h-- Installing: /usr/local/include/onnxruntime/core/framework/kernel_def_builder.h-- Installing: /usr/local/include/onnxruntime/core/framework/kernel_registry.h-- Installing: /usr/local/include/onnxruntime/core/framework/ml_value.h-- Installing: /usr/local/include/onnxruntime/core/framework/op_kernel.h-- Installing: /usr/local/include/onnxruntime/core/framework/op_kernel_info.h-- Installing: /usr/local/include/onnxruntime/core/framework/op_node_proto_helper.h-- Installing: /usr/local/include/onnxruntime/core/framework/ortdevice.h-- Installing: /usr/local/include/onnxruntime/core/framework/ortmemoryinfo.h-- Installing: /usr/local/include/onnxruntime/core/framework/run_options.h-- Installing: /usr/local/include/onnxruntime/core/framework/sparse_tensor.h-- Installing: /usr/local/include/onnxruntime/core/framework/tensor.h-- Installing: /usr/local/include/onnxruntime/core/framework/tensor_shape.h-- Installing: /usr/local/include/onnxruntime/core/providers/cpu-- Installing: /usr/local/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h-- Installing: /usr/local/include/onnxruntime/core/optimizer-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer.h-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer_level.h-- Installing: /usr/local/include/onnxruntime/core/optimizer/graph_transformer_utils.h-- Installing: /usr/local/include/onnxruntime/core/optimizer/rewrite_rule.h-- Installing: /usr/local/include/onnxruntime/core/optimizer/rule_based_graph_transformer.h-- Installing: /usr/local/include/onnxruntime/core/session-- Installing: /usr/local/include/onnxruntime/core/session/automl_data_containers.h-- Installing: /usr/local/include/onnxruntime/core/session/environment.h-- Installing: /usr/local/include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h-- Installing: /usr/local/include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_c_api.h-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_cxx_api.h-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_cxx_inline.h-- Installing: /usr/local/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h-- Installing: /usr/local/lib/libonnxruntime.so.1.5.2-- Installing: /usr/local/lib/libonnxruntime.so-- Installing: /usr/local/bin/onnx_test_runner

安装完成。


点击全文阅读


本文链接:http://zhangshiyu.com/post/90463.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1