Error when Importing tensorflow in embedded python in c++
Asked Answered
A

1

2

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.

Asteria answered 13/9, 2017 at 6:25 Comment(0)
A
0

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

Asteria answered 13/9, 2017 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.