-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fixed config.mk and Makefile bugs for installing mkl #15424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, LGTM. As I understand, variables in Makefile are case sensitive, this PR makes sense to me.
One question that I have about your description, where do we define USE_STATIC_MKL? I see it in files define ad-hoc but not in the Makefile or config.mk, could you edit the description and clarify where USE_STATIC_MKL is updated or add a comment in Makefile or config.mk or documentation? I didn't see it in the patch, maybe I missed something.
|
@mxnet-label-bot add [pr-awaiting-review] |
@nuslq Have you ever tried |
@larroy, USE_STATIC_MKL is updated in config.mk between lines 137 - 142, which I had put in the description. |
@TaoLv, Thanks for your suggestion! After further experiments, I found that changing lower case "use_blas" to capital format in Makefile would be able to build mxnet with "BLAS_MKL". The other change of setting "USE_BLAS=mkl" at different places (e.g. in commad line, at the end of config.mk, or before lines 137 - 142 of config.mk) would not make impact for this purpose. More specifically, without the changing lower case "use_blas" to capital format in Makefile, adding USE_BLAS=mkl in the make command line would not build mxnet with "BLAS_MKL". One thing to clarify here is that I used "make" instead of "cmake" to build mxnet from source. |
I think the lower cases BLAS check in Makefile was added for runtime feature detection. It's not really used for BLAS linkage. Please correct me if I'm wrong @larroy . |
Shouldn't USE_STATIC_MKL appear in the Makefile directly then? |
@larroy it's passed to and used in mshadow.mk. |
@TaoLv yes seems I introduced this, and was not correct due to case, apologies. This patch fixes that, I verified on mac and approved the PR, about MKL I think you are the best one to check that part. Since there's no real change to the former I already approved and verified. Thanks for the fix! |
@TaoLv, libmkldnn.so.0 => /home/ubuntu/incubator-mxnet/lib/libmkldnn.so.0 |
Thank you for confirming. @larroy @nuslq, this is as expected. libmkldnn.so and libmklml_intel.so will be dynamically linked even USE_STATIC_MKL is true. Actually, they are not the
Hope this explanation can address your questions. So the fix for lower case |
@mxnet-label-bot add [MKL, installation] |
Thanks for the explanation @TaoLv. Here are some questions inlined.
As far as we can trace, the only instance where the
I feel like there is more to understand which flags (as compiler and linker flags) are absolutely necessary for MxNet to compile with MKL BLAS support, using Could you or @larroy clarify what we're missing here? |
@yugoren Please find the definition of |
Thanks, that clears out how MKL is enabled by default in
That's why we felt it would be informative for the user to know exactly where to set the flag. Maybe we can change it to the following
@larroy What do you think? Another question: is |
Indeed this is messy and we should improve it, is difficult to reason about and track these flags. I suggest having this PR merged if anyone doesn't have any additional concerns to credit the contribution and adding additional PRs to improve the situation by clearly specifying the BLAS related flags in the compilation files and documenting them. |
@yugoren Can you double check? I can statically link MKL BLAS library by adding USE_BLAS=mkl to the make command line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nuslq thank you for the turn around. Approve now.
It would be better if you can also change the description of this PR:
This would not be corrected even if users set "USE_BLAS=mkl" at the end of the config.mk file or in the command line.
@nuslq Thank you for the changes. It's now merged. |
* fixed config.mk and Makefile bugs for installing mkl * remove comments from the previous changes
Description
UPDATES:
Based on the discussion below with @TaoLv , I have removed the comments for USE_BLAS=mkl in this PR because after testing we find that we can statically link MKL BLAS library by adding USE_BLAS=mkl to the make command line.
UPDATES:
I tried difference ways to build mxnet from source by hiding each or both of the two changes I made below, and found that only changing lower case "use_blas" to capital format in Makefile would be able to build mxnet with "BLAS_MKL". The other change, adding "USE_BLAS = mkl" before lines 137 - 142, would not make any impact for this purpose (although I am not sure whether or not this change would make impact at other places).
One thing to clarify here is that I used "make" instead of "cmake" to build mxnet from source.
(Brief description on what this PR is about)
I have found two bugs in the Makefile file and make/config.mk file in apache/incubator-mxnet package. These bugs might lead to incorrect installation of Mxnet with MKL library.
Before the changes, I could not find "BLAS_MKL" in mxnet.runtime.Features() outputs. After rebuilt my mxnet with the following changes, I found "BLAS_MKL" in mxnet.runtime.Features() outputs.
In the make/config.mk file, USE_BLAS will be first set to "atlas" for linux or "apple" for osx by default as follows (lines 119 - 124)
Later, the USE_STATIC_MKL would be set "NONE" if users did not set USE_BLAS to "mkl" before the following lines (lines 137 - 142).
This would not be corrected even if users set "USE_BLAS=mkl" at the end of the config.mk file or in the command line.(New test shows that USE_BLAS value, thereafter the USE_STATIC_MKL value, in config.mk can be overridden by adding USE_BLAS=mkl to the make command line)So, I correct this block to the follows,(removed this change for reason described above)In the Makefile, lines 247 - 255 as follows, I corrected the "use_blas" to capital form.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments