问题
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;
}
And the error is:
ConsoleApplication5.exe - Ordinal Not Found
The ordinal 225 could not be located in the dynamic link library libiomp5md.dll.
OK
And after pressing OK, this error appears in console:
Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.
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.
Thanks for your help.
回答1:
I've fixed this problem by copying libiomp5md.dll
from python library folder to directory of my C++ code.
来源:https://stackoverflow.com/questions/46190234/error-when-importing-tensorflow-in-embedded-python-in-c