【问题标题】:VS 2019, Tensorflow 2.6 C++, tensorflow::TensorInfo name() leads to The procedure entry point could not be located in the dynamic link libraryVS 2019,Tensorflow 2.6 C++,tensorflow::TensorInfo name()导致The procedure entry point could not be located in the dynamic link library
【发布时间】:2021-12-07 08:56:27
【问题描述】:

我有一个 C++ 项目,我正在加载一个保存的模型并想做一些推断。现在我有以下代码:

    Status status = LoadSavedModel(session_options, run_options, "final", { kSavedModelTagServe }, &model_bundle);
    auto sig_map = model_bundle.GetSignatures();
    auto model_def = sig_map.at("serving_default");
    for (auto const& p : model_def.inputs()) {
        std::cout << p.first.c_str() << std::endl;
        std::cout << p.second.name() << std::endl;
    }

当我执行成功构建的 exe 文件时,这个 sn-p 会导致以下错误消息:

The procedure entry point  could not be located in the dynamic link library

如果我将//std::cout &lt;&lt; p.second.name() &lt;&lt; std::endl; 注释掉,则一切都编译良好并且可执行文件也可以运行。因为 p.second 是 tensorflow::TensorInfo 类型,所以我也尝试创建这样的对象并调用 ti.name();,这也会导致同样的问题。

您能就如何解决这个问题提出任何建议吗? tensorflow_cc.dll 的编译是不是有些不对?

【问题讨论】:

    标签: c++ tensorflow dll linker tensorflow2.x


    【解决方案1】:

    问题非常简单。编译 tensorflow 时,您必须手动将缺少的导出符号添加到 tensorflow_filtered_def_file.def 并重新链接 tensorflow.dll。有一次,在重新链接 tensorflow.dll 并根据这个 dll 编译我自己的程序后,我忘记将新的 tensorflow.dll 复制到我正在测试我的程序的位置。因此,新的可执行文件无法与之前编译的 tensorflow.dll 一起使用,但由于它知道所有符号,因此在错误消息中显示为空符号。

    解决方案:确保在运行程序时使用与编译程序时相同的 tensorflow.dll。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 2022-12-28
      • 1970-01-01
      • 2021-11-07
      • 2020-12-18
      相关资源
      最近更新 更多