簡體   English   中英

pybind11 在導入 ONNX python 模塊時崩潰(分段錯誤(核心轉儲))

[英]pybind11 crashes (segmentation fault (core dumped)) while importing ONNX python module

我在我的 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")

我正在回答我自己的問題。 問題的原因是onnxprotobuf版本 3.19.0 或更高版本不兼容。 在 3.18.1 和 3.12.0 之間使用protobuf將解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM