【问题标题】:pybind11 crashes (segmentation fault (core dumped)) while importing ONNX python modulepybind11 在导入 ONNX python 模块时崩溃(分段错误(核心转储))
【发布时间】:2022-08-02 12:24:10
【问题描述】:

我在我的 C++ 代码中使用 pybind11。当我尝试导入onnx 时,我的代码与Segmentation fault (core dumped) 一起崩溃。但是,如果我导入onnxruntime,一切都很好。当然onnxonnxruntime 都通过pip 安装在我的系统上。

// installed libraries
pip install onnx
pip install onnxruntime
// C++ code
#include <pybind11/embed.h>

namespace py = pybind11;

py::module::import(\"onnxruntime\"); // This is okay
py::module::import(\"onnx\"); // This crashes with segmentation fault

导入行的顺序无关紧要。无论在哪里,py::module::import(\"onnx\") 都会因分段错误而崩溃。如何成功运行py::module::import(\"onnx\")

    标签: python c++ segmentation-fault pybind11 onnx


    【解决方案1】:

    我正在回答我自己的问题。问题的原因是onnxprotobuf 3.19.0 或更高版本不兼容。在 3.18.1 和 3.12.0 之间使用 protobuf 将解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-04
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      相关资源
      最近更新 更多