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

can compile with MKLDNN + MKLML but no MKL #15483

Closed
MaeThird opened this issue Jul 8, 2019 · 7 comments
Closed

can compile with MKLDNN + MKLML but no MKL #15483

MaeThird opened this issue Jul 8, 2019 · 7 comments
Labels

Comments

@MaeThird
Copy link

MaeThird commented Jul 8, 2019

Because MKL is really large and needs register in Intel' web. It's tedious in the production environment.
I tried to compile the mxnet with MKLDNN and MKLML without MKL but failed in the linking processing. It looks like the 'mshadow' module needs the MKL
I think if the entire MKL is convenient there will be no MKLML anymore. if the proj is not designed for production it's just a toy for ever.

@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

@MaeThird thanks for trying MXNet with MKLDNN backend.
Yes, it should work without MKL build even in mshadow.
Could you try the build with 'USE_BLAS=open`?

Please paste the error message when you build without MKL.

@pengzhao-intel
Copy link
Contributor

cc @yinghu5 @NeoZhangJianyu

@MaeThird
Copy link
Author

MaeThird commented Jul 9, 2019

Hi @pengzhao-intel
MKLDNN + MKLML + CBLAS( Atlas or OpenBlas) works as expected.
MKLDNN + MKLML + USE_BLAS_MKL=1 (Actually there was no MKL,I just replaced it with MKLML) with the error output:

 53%] Built target mxnet_static
[ 55%] Built target dmlc
[ 84%] Built target mkldnn
[ 84%] Built target libomp-needed-headers
[ 92%] Built target omp
[ 93%] Built target mxnet
[ 94%] Built target gtest
[ 94%] Built target gtest_main
[ 94%] Linking CXX executable mxnet_unit_tests
/usr/bin/ld: ../libmxnet.a(elemwise_unary_op_basic.cc.o): in function `void mxnet::op::UnaryOp::MKL_Compute<mxnet::op::mshadow_op::erf, mxnet::op::mkl_func::erf>(nnvm::NodeAttrs const&, mxnet::OpContext const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::vector<mxnet::TBlob, std::allocator<mxnet::TBlob> > const&)':
elemwise_unary_op_basic.cc:(.text._ZN5mxnet2op7UnaryOp11MKL_ComputeINS0_10mshadow_op3erfENS0_8mkl_func3erfEEEvRKN4nnvm9NodeAttrsERKNS_9OpContextERKSt6vectorINS_5TBlobESaISF_EERKSE_INS_9OpReqTypeESaISK_EESJ_[_ZN5mxnet2op7UnaryOp11MKL_ComputeINS0_10mshadow_op3erfENS0_8mkl_func3erfEEEvRKN4nnvm9NodeAttrsERKNS_9OpContextERKSt6vectorINS_5TBlobESaISF_EERKSE_INS_9OpReqTypeESaISK_EESJ_]+0x93): undefined reference to `vsErf'
/usr/bin/ld: elemwise_unary_op_basic.cc:(.text._ZN5mxnet2op7UnaryOp11MKL_ComputeINS0_10mshadow_op3erfENS0_8mkl_func3erfEEEvRKN4nnvm9NodeAttrsERKNS_9OpContextERKSt6vectorINS_5TBlobESaISF_EERKSE_INS_9OpReqTypeESaISK_EESJ_[_ZN5mxnet2op7UnaryOp11MKL_ComputeINS0_10mshadow_op3erfENS0_8mkl_func3erfEEEvRKN4nnvm9NodeAttrsERKNS_9OpContextERKSt6vectorINS_5TBlobESaISF_EERKSE_INS_9OpReqTypeESaISK_EESJ_]+0xf9): undefined reference to `vdErf'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/mxnet_unit_tests.dir/build.make:354: tests/mxnet_unit_tests] Error 1
make[1]: *** [CMakeFiles/Makefile2:1825: tests/CMakeFiles/mxnet_unit_tests.dir/all] Error 2

It turns out MKLML cannot replace the MKL as the blas using.
Another small issue is that [https://github.com/intel/mkl-dnn/blob/41bee20d7eb4a67feeeeb8d597b3598994eb1959/src/common/utils.cpp#L53] strncpy(value, buffer, value_length);will case

In file included from /usr/include/string.h:494,
                 from /home/mae/mxnet/incubator-mxnet/3rdparty/mkldnn/src/common/utils.cpp:17:
In function ‘char* strncpy(char*, const char*, size_t)’,
    inlined from ‘int mkldnn::impl::mkldnn_getenv(char*, const char*, int)’ at /home/mae/mxnet/incubator-mxnet/3rdparty/mkldnn/src/common/utils.cpp:53:24:
/usr/include/bits/string_fortified.h:106:34: error: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mae/mxnet/incubator-mxnet/3rdparty/mkldnn/src/common/utils.cpp: In function ‘int mkldnn::impl::mkldnn_getenv(char*, const char*, int)’:
/home/mae/mxnet/incubator-mxnet/3rdparty/mkldnn/src/common/utils.cpp:49:34: note: length computed here
   49 |             value_length = strlen(buffer);

with GCC-9.1 . It's handy to fix it.

@pengzhao-intel
Copy link
Contributor

pengzhao-intel commented Jul 9, 2019

MKLDNN + MKLML + USE_BLAS_MKL=1 (Actually there was no MKL,I just replaced it with MKLML) with the error output:

This is not the right usage because MKLML is just a subset of MKL and only works for MKL-DNN library.
It doesn't target to work as a full BLAS library.

You can get MKL by yum or apt to avoid web register.
https://software.intel.com/en-us/articles/installing-intel-free-libs-and-python-yum-repo
https://software.intel.com/en-us/articles/installing-intel-free-libs-and-python-apt-repo

As you see the "vsErf" is not included in MKLML but it's a part of MKL.

cc @TaoLv

@MaeThird
Copy link
Author

MaeThird commented Jul 9, 2019

@pengzhao-intel Thanks for your help.

@MaeThird MaeThird closed this as completed Jul 9, 2019
@TaoLv
Copy link
Member

TaoLv commented Jul 9, 2019

Thanks for pinging, @pengzhao-intel .

@MaeThird ,

Regarding the first error, yes, the vsErf function is not part of MKLML. So you need full MKL to take advantage of this function.
Regarding the compiling error with GCC 9+, it's fixed in MKL-DNN 0.20 release and just upstreamed to mxnet half an hour ago (#15422). Would you mind trying the master branch to see if the error is still there?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants