在 C++ 中的嵌入式 python 中导入 tensorflow 时出错

Error when Importing tensorflow in embedded python in c++

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

#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 - Ordinal Not Found

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

OK

按确定后,控制台出现此错误:

Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.

我的设置是 Windows 7 x64、Anaconda Python 3.5.2、tensorflow-1.1.0 和 CUDA 8。

This 是一个类似的问题,但有不同的错误。

感谢您的帮助。

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