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

Default cmake build uses openblas instead of MKL #14085

Closed
stsukrov opened this issue Feb 7, 2019 · 9 comments
Closed

Default cmake build uses openblas instead of MKL #14085

stsukrov opened this issue Feb 7, 2019 · 9 comments
Labels
Bug Build CMake CMake related bugs/issues/improvements Performance

Comments

@stsukrov
Copy link

stsukrov commented Feb 7, 2019

Description

Default CUDA-free build links to openblas AND mkl. openblas is used instead of mkl, which leads to pure performance.

Environment info (Required)

----------Python Info----------
Version : 3.5.2
Compiler : GCC 5.4.0 20160609
Build : ('default', 'Nov 12 2018 13:43:14')
Arch : ('64bit', 'ELF')
------------Pip Info-----------
Version : 8.1.1
Directory : /usr/lib/python3/dist-packages/pip
----------MXNet Info-----------
Version : 1.5.0
Directory : /home/stsukrov/workspace/mxnet/python/mxnet
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform : Linux-4.4.0-1074-aws-x86_64-with-Ubuntu-16.04-xenial
system : Linux
node : ip-172-31-1-212
release : 4.4.0-1074-aws
version : #84-Ubuntu SMP Thu Dec 6 08:57:58 UTC 2018
----------Hardware Info----------
machine : x86_64
processor : x86_64
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 72
On-line CPU(s) list: 0-71
Thread(s) per core: 2
Core(s) per socket: 18
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz
Stepping: 4
CPU MHz: 3000.000
BogoMIPS: 6000.00
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 25344K
NUMA node0 CPU(s): 0-17,36-53
NUMA node1 CPU(s): 18-35,54-71
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single kaiser fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f rdseed adx smap clflushopt clwb avx512cd xsaveopt xsavec xgetbv1 ida arat pku
----------Network Test----------
Setting timeout: 10
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0155 sec, LOAD: 0.0708 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0348 sec, LOAD: 0.2342 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0010 sec, LOAD: 0.3944 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0896 sec, LOAD: 0.7671 sec.
Timing for MXNet: /~https://github.com/apache/incubator-mxnet, DNS: 0.0006 sec, LOAD: 0.9998 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.2689 sec, LOAD: 1.0834 sec.

Compiler (gcc/clang/mingw/visual studio):
gcc-5
MXNet commit hash: d684c59

Build config:
cmake -DUSE_CUDA=OFF

tracing the line used to link the libmxnet.so produces

/home/stsukrov/cmaketmp/cmake-3.13.2-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/mxnet.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -Wall -Wno-unknown-pragmas -Wno-sign-compare -O3 -msse2 -std=c++11 -mf16c -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -fopenmp -std=c++0x -shared -Wl,-soname,libmxnet.so -o libmxnet.so CMakeFiles/mxnet.dir/dummy.c.o -L/home/stsukrov/workspace/incubator-mxnet/build/mklml/mklml_lnx_2019.0.1.20180928/lib -Wl,-rpath,/home/stsukrov/workspace/incubator-mxnet/build/3rdparty/mkldnn/src:/home/stsukrov/workspace/incubator-mxnet/build/3rdparty/openmp/runtime/src:/home/stsukrov/workspace/incubator-mxnet/build/mklml/mklml_lnx_2019.0.1.20180928/lib: -Wl,--whole-archive libmxnet.a -Wl,--no-whole-archive libmxnet.a 3rdparty/mkldnn/src/libmkldnn.so.0.17.1.0 -lopenblas -lrt -ljemalloc /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.9 /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4.9 3rdparty/openmp/runtime/src/libomp.so -lpthread -llapack -ljemalloc 3rdparty/dmlc-core/libdmlc.a -lpthread -llapack -lmklml_intel mklml/mklml_lnx_2019.0.1.20180928/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.9 -lpthread -ldl

So blas is linked before mklml_intel

Minimum reproducible example

Get the mxnet, build it, run the benchmark

Steps to reproduce

(Paste the commands you ran that produced the error.)

  1. git clone --recursive ...
  2. mkdir build && cd build
  3. cmake -DUSE_CUDA=OFF
  4. make -j20
  5. ldd libmxnet
  6. Run /~https://github.com/apache/incubator-mxnet/blob/master/example/image-classification/benchmark_score.py

What have you tried to solve it?

  1. Linked manually to mklml_intel with a brutal fix: stsukrov@eebc17b
  2. Rerun the benchmark
  3. Got the declared performance
@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

@stsukrov
Copy link
Author

stsukrov commented Feb 7, 2019

@mxnet-label-bot add [bug, build, cmake]

@marcoabreu marcoabreu added Bug Build CMake CMake related bugs/issues/improvements labels Feb 7, 2019
@stsukrov
Copy link
Author

stsukrov commented Feb 7, 2019

@mxnet-label-bot add [bug, performance]

@pengzhao-intel
Copy link
Contributor

@lebeg is working on the fixing for cmake and BLAS related issues.

@stsukrov
Copy link
Author

stsukrov commented Feb 8, 2019

Thanks, Patric!

I'm in contact with @lebeg and we will track the issue.

@lebeg
Copy link
Contributor

lebeg commented Feb 12, 2019

Yes, it is a significant problem. I did fix it in #11148, but fix was never merged. I think initially the thought behind it was that presumably MKLML wouldn't have all necessary math functions included and therefore openblas was linked to cover this cases. In reality MKLML functionality is fully sufficient, so openblas should not be linked at all when MKL or MKLML is used.

@NeoZhangJianyu
Copy link
Contributor

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

@pengzhao-intel
Copy link
Contributor

Closing. Feel free to reopen if any issue is observed again.

@stsukrov
Copy link
Author

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Build CMake CMake related bugs/issues/improvements Performance
Projects
None yet
Development

No branches or pull requests

6 participants