Description
Description
Build MXNet with Intel MKLML under Linux will link with incorrect MKL library instead of MKLML library due to a bug in prepare_mkl.sh.
The root cause is in prepare_mkl.sh USE_MKLML flag is wrongly set to 0 even when compiling with MKLML which make libmxnet.so linked with unexpected MKL library.
To be more accurate, there is issue in below find statement (in prepare_mkl.sh line 118) that would return empty even libmklml_gnu.so exists under MKLROOT directory.
if [ -z find $MKLROOT -name libmklml_gnu.so -o -name libmklml.dylib -print -quit ]
The fix should be something like below (like add bracket to embrace the "or" logic):
diff --git a/prepare_mkl.sh b/prepare_mkl.sh
index 97a1e49..e048f59 100755
--- a/prepare_mkl.sh
+++ b/prepare_mkl.sh
@@ -115,7 +115,7 @@ if [ -z $MKLROOT ]; then
fi
\# Check what MKL lib we have in MKLROOT
-if [ -z find $MKLROOT -name libmklml_gnu.so -o -name libmklml.dylib -print -quit ]; then
+if [ -z find $MKLROOT \( -name libmklml_gnu.so -o -name libmklml.dylib \) -print -quit ]; then
USE_MKLML=0
elif [ -z find $MKLROOT -name libmkl_core.so -print -quit ]; then
USE_MKLML=1
Build info (Required if built from source)
Compiler: GCC
HW: Intel CPU
MXNet commit hash:
ae0fe77
Build command:
make -j 12 USE_OPENCV=1 USE_MKL2017=1 USE_MKL2017_EXPERIMENTAL=1 USE_BLAS=mkl USE_PROFILER=1 MKLML_ROOT=/home/jinhuang/downloads/mklml_lnx_2018.0.1.20171007
What have you tried to solve it?
- Applied a fix in prepare_mkl.sh to fix this issue.
- Added a test script to check if MKLML is installed correctly (linked with expected MKLML library) after
build/install. - After the fix, MXNet with MKLML could be compiled successfully, and the image training performance is about 42.66 images/sec on skylake 8180 using bs64 (use train_imagenet.py script)
Other info: similar issue is also reported in another thread #8881