Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes mklml is much slower than mkl. #4813

Closed
gongweibao opened this issue Oct 15, 2017 · 17 comments
Closed

Sometimes mklml is much slower than mkl. #4813

gongweibao opened this issue Oct 15, 2017 · 17 comments
Assignees

Comments

@gongweibao
Copy link
Contributor

gongweibao commented Oct 15, 2017

If we use mkl, the model's forward time is 0.03ms in contrast to 2ms when we use mklml library.
Env is put here and you can use this environment to reproduce the problem.

@luotao1
Copy link
Contributor

luotao1 commented Oct 16, 2017

有几个问题想确认下:

  1. 请问复现的步骤是什么?分别编译出使用mklml和使用mkl的两个paddle版本,然后直接跑测试环境中的run.sh脚本?这个测试环境是一个独立于paddle repo的文件夹?
  2. 测试环境中的CMakeLists文件中,有很多写死的路径。这些路径应该是什么?
  3. 是在独占节点上测试得到的结果么?trainer_count是几?

@tensor-tang
Copy link
Contributor

补充一个问题,请问所用的mkl版本是什么?相比于mklml的时候,单节点时的cpu利用率分别是多少?

@gongweibao
Copy link
Contributor Author

mkl库已经不可查,公司内部以前大家用的。可以在https://hub.docker.com/r/paddlepaddle/centos6u3-capi/里边的/opt/intel/mkl目录下找到

@gongweibao
Copy link
Contributor Author

1.请问复现的步骤是什么?
分别使用mklml编译出.so和公司内部mkl编译出来的.so,测试其时间
2.测试环境中的CMakeLists文件中,有很多写死的路径。这些路径应该是什么?
那些是使用的第三方.a文件。我把它们打包发上去。
3. 是在独占节点上测试得到的结果么?
独占节点的结果。

@luotao1
Copy link
Contributor

luotao1 commented Nov 16, 2017

  1. 公司内部mkl编译出来的.so也放上去吧。
  2. https://github.com/gongweibao/tests/tree/develop/zhangtai 这个拉下来就可以跑,直接运行run.sh?能把里面写死的路径都改一下么?

@gongweibao
Copy link
Contributor Author

不好意思各位,回复的完了。已经把环境整理的比较整洁了。看大家还有啥问题没有?

@luotao1
Copy link
Contributor

luotao1 commented Nov 16, 2017

https://github.com/gongweibao/tests/blob/develop/build_capi/build_capi.sh#L22 这里看WITH_MKLML=ON,但从https://github.com/gongweibao/tests/tree/develop/zhangtai/mkl/lib 看缺少libiomp5.solibmklml_intel.so这两个库。

@gongweibao
Copy link
Contributor Author

给出的是链接mkl库的版本,链接他的时候不需要你说的这两个库。

find ./third_party/install -name 'libiomp5.so' -exec cp {} output/usr/local/lib \;

找不到不会拷贝过去的。

@luotao1
Copy link
Contributor

luotao1 commented Nov 16, 2017

libiomp5.so是使用mklml库的时候,才有的。那使用mklml编译出.so的时候,有用到这两个库么?

给出的是链接mkl库的版本

那使用mklml库的版本是在哪里?

@gongweibao
Copy link
Contributor Author

这个我以为你要自己编,出现diff的时候可以加参数来调整。
我可以加一个上去。

@luotao1
Copy link
Contributor

luotao1 commented Nov 16, 2017

https://github.com/gongweibao/tests/tree/develop/zhangtai/mkl/lib 这个是链接公司内部mkl库的版本?从lib中看不到公司内部mkl的so文件。

这个我以为你要自己编?

我可以自己编,但我要怎么编译呢?因为对这个project不熟悉,而README中只给出了编译环境,没给出编译命令。所以请问能不能把两个版本的所有环境都放上去,然后写一下分别是怎么编译得到的?

另外,README写了“然后看其打印的时间作对比”。请问要运行哪个文件?

单节点时的cpu利用率分别是多少

也麻烦回答一下这个问题。

初步怀疑,下降10倍,是因为编译的时候没有开启WITH_MKLML=ON的选项,只开启了WITH_MKLDNN=ON

@gongweibao
Copy link
Contributor Author

image

@gongweibao
Copy link
Contributor Author

gongweibao commented Nov 16, 2017

这个是链接公司内部mkl库的版本?从lib中看不到公司内部mkl的so文件。

公司内部 mkl库是一个.a,不是.so,link的时候被包含在了libpaddle_capi_shared.so

我可以自己编,但我要怎么编译呢?因为对这个project不熟悉,而README中只给出了编译环境,没给出编译命令。所以请问能不能把两个版本的所有环境都放上去,然后写一下分别是怎么编译得到的?

写进去了

另外,README写了“然后看其打印的时间作对比”。请问要运行哪个文件?

写进去了

单节点时的cpu利用率分别是多少

看上图

@gongweibao
Copy link
Contributor Author

由于mklml的.so超过了50M,不能传到github上。
需要的话我可以单独发,或者可以自己编译一下。编译版本和命令都已经写到README当中。

@gongweibao
Copy link
Contributor Author

运行时间对比:
image

@luotao1 luotao1 added the MKL label Nov 27, 2017
@luotao1
Copy link
Contributor

luotao1 commented Dec 12, 2017

问题已复现。
进入docker环境后,由于MKLML是动态库,所以需要设置了如下变量:

export KMP_AFFINITY="granularity=fine,compact,0,0"
export OMP_DYNAMIC="FALSE"
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1

image
从图中看两者差距在1.3倍。

@luotao1
Copy link
Contributor

luotao1 commented Dec 12, 2017

https://github.com/gongweibao/testcapi/blob/master/main.cpp#L124 一次循环时间改成十次,两者时间是一样了
image

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

No branches or pull requests

3 participants