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

[MKLDNN] Question on installation and use of MKLDNN #14335

Closed
dbsxdbsx opened this issue Mar 5, 2019 · 12 comments
Closed

[MKLDNN] Question on installation and use of MKLDNN #14335

dbsxdbsx opened this issue Mar 5, 2019 · 12 comments

Comments

@dbsxdbsx
Copy link

dbsxdbsx commented Mar 5, 2019

Target
I am trying to build mxnet from source to use with python and C++ on win10_64, and with MKL+MKLDNN as backbone.

I KNOW what I stated below may be TOO MUCH, but I do think these questions are representative, as I've googled A LOT before, and still not solved.

Question on installation
With the latest CMakeList.txt in mxnet source,I see:

mxnet_option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON)
mxnet_option(USE_MKLML_MKL        "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE))
mxnet_option(USE_MKLDNN           "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE) AND (NOT MSVC) AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") AND (NOT CMAKE_CROSSCOMPILING))

(Here, I know MKL is the basic intel lib can be installed alone. MKLML_MKL is a sub module of MKL. MKLDNN is lib optimized for deep learning especially, it can be used alone or with MKL( FULL INSTALLTION or MKLML_MKL) or even other blas lib. And from Intel MKLDNNoffically, seems MKL(FUll Installation)+MKLDNN would give the best performance---that is what I want to try. And I've FULLY installed MKL manually before.)

Q1: why the explanation of USE_MKLML_MKL and USE_MKLDNN are all the same, it is confusing. I did found an issue talking about this, but it is still confusing. And after checking CMakeList.txt superficially, I don't know what variable USE_MKLML_MKL is used for?

Q2: from office tutorial of gluonCV with C++, seems it is feasible to build with MKL+MKLDNN in cmd command. But with CMake Gui, USE_MKLDNN is forbidden, as it need (NOT MSVC) . WHY?

Q3: To build MKLDNN with MKL(full installed but NOT submodule), with mxnet official tutorial here, I need to:
Copy file 3rdparty/mkldnn/config_template.vcxproj to incubator-mxnet root.But I only found config_template.vcxproj.user, does that mean I could build mxnet with MKL+MKLDNN after I copy it to the root path of mxnet but with NO selection of USE_MKLDNN when configuring with CMAKE Gui?

Q4: I googled a lot on MKl with mxnet, and I found a discussion within mxnet team, with the content of the discussion and what I found in downloadMKLML.cmake, does it mean mxnet recommand install MKLDNN with JUST submodule of MKL at present(and it is still vague to decide whether submodule of MKL is needed when building mxnet from source)?
(As far as I know,to build MKLDNN LIB, there is no need to download a submodule of MKL once MKL is FULL installed. And I did succeed without doing it within building mxnet.)

Question on usage of MKL
I know mxnet is just released a new version 1.4, with some update of MKL(+DNN). But after looking into tutorial MKLDNN_README, With MKL+MKLDNN built with mxnet 1.4,I wonder

Q1: does it mean that MKL+MKLDNN is automatically used in cpu mode with net graph BUT NOT include SUBGRAPH without setting an OS variable MXNET_SUBGRAPH_BACKEND=MKLDNN when using mxnet lib?

Q2: For optimization, is MXNET_SUBGRAPH a concept that always existed within a net graph, if so, I guess there is no need to set OS variable MXNET_SUBGRAPH_BACKEND any longer when the feature is matured?

@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: Installation, Build

@dbsxdbsx dbsxdbsx changed the title Question on installation and use of MKLDNN [MKLDNN] Question on installation and use of MKLDNN Mar 5, 2019
@piyushghai
Copy link
Contributor

@dbsxdbsx Thanks for raising this question. For questions, please submit them on MXNet discussion forum (https://discuss.mxnet.io), where it will get a wider audience and allow others to learn as well.

Thanks!

@mxnet-label-bot Add [Question, MKL, MKLDNN]

@pengzhao-intel
Copy link
Contributor

@dbsxdbsx really thanks for the usage of MKLDNN backend.
In general, the window supports of MKLDNN is not mature at now. Some workarounds are needed.
Sorry for the inconvenience. But we're working on the improvements.

@xinyu-intel @TaoLv will help you with the specific questions and building issues.

@pengzhao-intel
Copy link
Contributor

@mxnet-label-bot Add [Windows]

@TaoLv
Copy link
Member

TaoLv commented Mar 11, 2019

@dbsxdbsx could you post the steps for reproducing the build issue? Or typical steps for building mxnet from a Windows user perspective. I also sent an email to you for details.

Try to answer part of the questions:

Q2: from office tutorial of gluonCV with C++, seems it is feasible to build with MKL+MKLDNN in cmd command. But with CMake Gui, USE_MKLDNN is forbidden, as it need (NOT MSVC) . WHY?

It's possible to build MXNet with MKL/MKL-DNN from source. Please take a look at what we do in CI:
https://github.com/apache/incubator-mxnet/blob/master/ci/docker/runtime_functions.sh#L553
https://github.com/apache/incubator-mxnet/blob/master/ci/docker/runtime_functions.sh#L708
I'm not a CMAKE GUI user, so not sure what's the problem on it.

Q4: I googled a lot on MKl with mxnet, and I found a discussion within mxnet team, with the content of the discussion and what I found in downloadMKLML.cmake, does it mean mxnet recommand install MKLDNN with JUST submodule of MKL at present(and it is still vague to decide whether submodule of MKL is needed when building mxnet from source)?

Currently, it is much easier to get MKLML compared with to get full MKL. It has more friendly license to mxnet, smaller binary size and more convenient download source. So now it's the default behavior to download MKLML and link to it when mxnet is built with USE_MKLDNN=1. But you're right, there is no need to link MKLML if full MKL is installed and linked to mxnet.

@dbsxdbsx
Copy link
Author

@pengzhao-intel @TaoLv , Actually, for the past several days, I've succeeded in build mxnet on win10 with FULL MKL+MKLDNN, and run it in python. But not yet in C++ because of issue #14116.
But what I did is just too complicated as I modified a lot within mxnet cmakelist and some other files.

Now I am trying to clear and note everything useful during my compiling. Once it is done, I would post it here, but maybe in Chinese, not English. Hope it is helpful.

@TaoLv
Copy link
Member

TaoLv commented Mar 11, 2019

You're very welcomed to contribute them back to mxnet.

@dbsxdbsx
Copy link
Author

@TaoLv @pengzhao-intel ,Finally, I made it. Too exhausting! link here. Hope it is helpful.

@TaoLv
Copy link
Member

TaoLv commented Mar 11, 2019

@dbsxdbsx Really nice summary! Will follow it and try to reproduce the issue.

@NeoZhangJianyu
Copy link
Contributor

@dbsxdbsx This issue has been fixed totally by #14877.
You could try in latest master branch.

@dbsxdbsx
Copy link
Author

@NeoZhangJianyu ,thanks.

@pengzhao-intel
Copy link
Contributor

The question is answered so closing

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

7 participants