在C ++中的嵌入式Python中导入Tensorflow时出错 [英] Error when Importing tensorflow in embedded python in c++

查看:149
本文介绍了在C ++中的嵌入式Python中导入Tensorflow时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于将Python 3.5解释器嵌入C ++程序以从C ++接收图像,并将其用作我训练有素的Tensorflow模型的输入.当我在python代码中导入tensorflow库时出现错误(其他库工作正常).简化的代码如下:

My question is regarding embedding Python 3.5 interpreter in a C++ program to receive an image from C++, and use it as an input for my trained tensorflow model. When I import tensorflow library in my python code I get an error (other libraries work fine). The simplified code is as follows:

#include <string>
#include <windows.h>
#include <stdio.h>


int main()
{
    Py_InitializeEx(1);

    PyObject* sysPath = PySys_GetObject((char*)"path");
    PyObject* curDir = PyUnicode_FromString(".");
    PyList_Append(sysPath, curDir);
    Py_DECREF(curDir);


    PyRun_SimpleString("import tensorflow\n"
        "print(tensorflow.__version__)\n");


    Py_Finalize();
    return 0;
}

错误是:

ConsoleApplication5.exe-找不到序号

ConsoleApplication5.exe - Ordinal Not Found

序号225不能位于动态链接库中 libiomp5md.dll.

The ordinal 225 could not be located in the dynamic link library libiomp5md.dll.

按确定"后,此错误将出现在控制台中:

And after pressing OK, this error appears in console:

英特尔MKL致命错误:无法加载mkl_intel_thread.dll.

Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.

我的设置是在Windows 7 x64,Anaconda Python 3.5.2,tensorflow-1.1.0和CUDA 8上进行的.

My setup is on Windows 7 x64, Anaconda Python 3.5.2, tensorflow-1.1.0 and CUDA 8.

是类似的问题,但有不同的错误.

This is a similar problem with a different error.

感谢您的帮助.

推荐答案

我已通过将libiomp5md.dll从python库文件夹复制到我的C ++代码目录中来解决此问题.

I've fixed this problem by copying libiomp5md.dll from python library folder to directory of my C++ code.

这篇关于在C ++中的嵌入式Python中导入Tensorflow时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆