无法运行使用MKL编译的TensorFlow

时间:2017-08-21 03:02:20

标签: c++ tensorflow compilation intel intel-mkl

我已经在Ubuntu 16.04上使用CUDA和MKL编译了最新的TensorFlow,如此

bazel build --config=opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --config=mkl --config=cuda //tensorflow/tools/pip_package:build_pip_package

现在,当我试图运行它时,我收到一条错误消息,指出无法找到某个intel的库。我还发现其他正在安装不同DNN框架的人正在努力解决此问题https://github.com/PaddlePaddle/Paddle/issues/3213并找到了一个英特尔文档https://software.intel.com/en-us/articles/intel-mkl-dnn-part-1-library-overview-and-installation,它基本上说当您按照该文档中的说明操作时这些文件应该可用据我所知。我遵循了这些指示,一切似乎都有效,但实际上libmklml_intel.solibiomp5.so文件未添加到/usr/local/lib

>>> import tensorflow

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libmklml_intel.so: cannot open shared object file: No such file or directory

编辑: 实际上,在我克隆了/mkl-dnn/external/mklml_lnx_2018.0.20170720/lib git并按照https://software.intel.com/en-us/articles/intel-mkl-dnn-part-1-library-overview-and-installation

中的说明后,它们位于mkl-dnn

1 个答案:

答案 0 :(得分:2)

实际上,在我克隆了mkl-dnn git并遵循https://software.intel.com/en-us/articles/intel-mkl-dnn-part-1-library-overview-and-installation

中的指示后,这些库位于/mkl-dnn/external/mklml_lnx_2018.0.20170720/lib

所以我将它们复制到/usr/local/lib并将这些文件夹包含在.bashrc中作为

export LIBRARY_PATH = / usr / local / lib:$ LIBRARY_PATH export LD_LIBRARY_PATH = / usr / local / lib:$ LD_LIBRARY_PATH

并重新加载.bashrc

source ~/.bashrc

现在TensorFlow正常运作。