apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.78k stars 6.79k forks source link

Default cmake build uses openblas instead of MKL #14085

Closed stsukrov closed 5 years ago

stsukrov commented 5 years ago

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: d684c59049970794e8f7365f58b03e13801b44a3

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: https://github.com/stsukrov/incubator-mxnet/commit/eebc17b04602b448686231a9e1fd1722bf919da7
  2. Rerun the benchmark
  3. Got the declared performance
mxnet-label-bot commented 5 years ago

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 commented 5 years ago

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

stsukrov commented 5 years ago

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

pengzhao-intel commented 5 years ago

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

stsukrov commented 5 years ago

Thanks, Patric!

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

lebeg commented 5 years ago

Yes, it is a significant problem. I did fix it in https://github.com/apache/incubator-mxnet/pull/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 commented 5 years ago

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

pengzhao-intel commented 5 years ago

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

stsukrov commented 5 years ago

Thanks!