Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Cannot generate op.h when build with mkl #14343

Closed
stereomatchingkiss opened this issue Mar 6, 2019 · 14 comments
Closed

Cannot generate op.h when build with mkl #14343

stereomatchingkiss opened this issue Mar 6, 2019 · 14 comments

Comments

@stereomatchingkiss
Copy link

  • os : windows 10 64bits
  • compiler : vc2015 64bits update 3
  • mxnet : 1.3.1

I write down the steps of building at stackoverflow, please read it until step 14 if you want to know the details.

I use python download from here to generate op.h, but it throw error message

2>  "Running: OpWrapperGenerator.py"
2>  Traceback (most recent call last):
2>    File "OpWrapperGenerator.py", line 432, in <module>
2>      raise(e)
2>    File "OpWrapperGenerator.py", line 426, in <module>
2>      f.write(patternStr % ParseAllOps())
2>    File "OpWrapperGenerator.py", line 320, in ParseAllOps
2>      cdll.libmxnet = cdll.LoadLibrary(sys.argv[1])
2>    File "C:\Users\yyyy\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 434, in LoadLibrary
2>      return self._dlltype(name)
2>    File "C:\Users\yyyy\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
2>      self._handle = _dlopen(self._name, mode)
2>  OSError: [WinError 193] %1 is not a valid Win32 application

Dependency of libmxnet.dll(by dumpbin)

mkl_rt.dll
KERNEL32.dll
VCOMP140.DLL

Dependency of mkl_rt.dll(by dumpbin)

KERNEL32.dll

I put both of the dll, mkl_rt.dll and libmxnet.dll into a folder could be found by the os, try to generate op.h again, but it still give me the same error, how could I solve this issue? Thanks

ps : Use Anaconda3 can generate op.h, but it cause another issue " Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll."

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Build

@pengzhao-intel
Copy link
Contributor

Thanks, I see you raise the issue in the gluon forum.
@xinyu-intel is looking for the issue and will reply to you soon.

@piyushghai
Copy link
Contributor

@mxnet-label-bot Add [MKL, Build]

@stereomatchingkiss
Copy link
Author

stereomatchingkiss commented Mar 7, 2019

@xinyu-intel is looking for the issue and will reply to you soon.

Thanks, by the way, I build mxnet 1.3.1 with gpu and find out I can use gpu to do the inference task(with mxnet v1.3.1), but when I switch to cpu, it throw the same error again " Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll."

Edit : it is caused by MXExecutorForward in the Forward function, need to dig deeper to find out the culprit

@Bumblebee1964
Copy link

Hi,

you need include the right folder of the Intel MKL software package on your PATH env. var. It is probably "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\redist\intel64\mkl" .

I do not have access to my develop PC to check.

Also, if you have configured OpenCV, you need to add the folder containing the binaries of this project to the PATH. Same for CUDNN support.

Good luck

By the way, are you able to compile c++ program with op.h included without errors?

@stereomatchingkiss
Copy link
Author

stereomatchingkiss commented Mar 7, 2019

"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\redist\intel64\mkl" .

No use, I copied every dll in that folder and put them into the same folder with the exe, but it still give me the same error

if you have configured OpenCV

No, I don' need to build im2rec by myself, gluoncv installed by pip got that exe

Same for CUDNN support.

mxnet with CUDNN works fine, but cpu with mkl do not

By the way, are you able to compile c++ program with op.h included without errors?

It got lots of error because many arguments(learning rate and weigth decay of each functions) do not declare the type, I make them as mx_float manually then it work.

Thanks for your helps, you could study the post I put at stackoverflow, it mention how do I build the mxnet1.3.1 and every solutions I have tried.

I guess this problem wouldn't be able to solve unless someone dig into the codes

@stereomatchingkiss
Copy link
Author

The libs I link to in my small program are opencv_world342.lib and libmxnet.lib, do I need to link with more lib?

ps : I build the mxnet without opencv, but my program use opencv to read the image

@Bumblebee1964
Copy link

Bumblebee1964 commented Mar 7, 2019

If you use opencv to read the image, you might need the release folder of opencv in your PATH.
I got 1.3.0 without CUDA but with MKL running on Windows 10 with CPP_PACKAGE.

Also I got 1.3.1 compiled (same compile errors) and running with both CUDA and MKL support. But my own program crashes without any warnings/log messages when I call NDArray::WAitall after calling the executor.

I did not attempt to use MKL_DNN or MKLML. As the CMake file has the condition IF NOT MSVC. Although the doc I found, stated that these can be enabled.

When I am back on Monday on the office, I will look at the notes I made for CUDA/MKL.

I am working 2 years with mxnet . With python everything is fine. But getting it compiled and running on Windows/CPP_Package is a real struggle. Sparsely/flaky documented, often new build errors.

@stereomatchingkiss
Copy link
Author

stereomatchingkiss commented Mar 7, 2019

If you use opencv to read the image, you might need the release folder of opencv in your PATH.

Yes, I already put them into PATH. My solution is create a global_dll folder and add it into my PATH, this way I could switch different dll easier without adding too many PATH. Add so many PATH could cause some nasty troubles.

I did not attempt to use MKL_DNN or MKLML

I did not use MKLML either, because the CMake file of mshadow will forced to use openBLAS

I will look at the notes I made for CUDA/MKL.

Thanks

getting it compiled and running on Windows/CPP_Package is a real struggle. Sparsely/flaky documented, often new build errors.

Know your pain, guess I should give 1.3.0 a try. If things are like this since two years ago, that means windows/CPP_Package is not their major concern. 1.3.1 can't build with openBLAS(maybe it is because I update vc2015) and got runtime issues on cpu version. 1.4.0 can't compile on windows, many bugs.

With python everything is fine.

mxnet installed by pip works well on my pc too, api of gluoncv and mxnet are well designed, but python is not the right tool when I want to deploy my app, I need c++ for this kind of tasks, unless most of my customers ask me to make the app able to run on windows, windows still dominate 90% of desktop market.

dnn module of opencv4 planning to support cuda and cudnn, hope it can success so we could have a tool easier to build and use.

@stereomatchingkiss
Copy link
Author

stereomatchingkiss commented Mar 8, 2019

I guess I found the issue, you need to enable MKL_USE_ILP64(I am surprise it can compile before I actiave it, even my pc only install MKL with 64 bits), else the mxnet will try to build with 32bits library, but the problem is when you enable that options, you will get tons of compile time errors.

Edit : please check #14364 for more details

@smissan
Copy link

smissan commented Mar 21, 2019

is there a workaround for this issue? Will it work without mkl? Or is c++ build completely broken?

@Bumblebee1964
Copy link

For me it works (version 1.3.0) with CUDA 9.2, CUDNN 7, OPENCV 3.4.4 with VS2017 and Windows 10. OpenCV was complied without MKL support.

Version 1.4.x compiles with same config (except opencv3.4.5), but I did not link it yet to my application.

On [https://zhuanlan.zhihu.com/p/58918998] you find a quite good guide I guess, my script is almost the same. Maybe you have to translate to English (I did).

@Bumblebee1964
Copy link

A note on gtest and gtest_main projects, I set option "Treat warnings as errors" on "no" (compiler option /WX-)
Otherwise the projects do not compile.

@bgawrych
Copy link
Contributor

bgawrych commented Jul 6, 2021

I was able to build properly 1.x and 2.0 on windows 10 with cmake - @szha I think we can close this one as outdated - @stereomatchingkiss if you don't agree feel free to reopen and ping me

@leezu leezu closed this as completed Jul 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants