Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Unable to compile TF 1.3 from source using full MKL

Renshaw__Daniel
Beginner
1,341 Views

I have tried to compile TensorFlow with the full MKL but this failed. I logged an issue on the TensorFlow GitHub but since the MKL integration is provided by Intel they are unable to help there. Could you please look at the issue: https://github.com/tensorflow/tensorflow/issues/12849

Steps to reproduce:

git clone https://github.com/tensorflow/tensorflow.git test
cd test
git checkout r1.3
yes "" | TF_NEED_CUDA=0 TF_NEED_MKL=1 TF_DOWNLOAD_MKL=0 MKL_INSTALL_PATH=<path>/l_mkl_2017.3.196/inst/mkl ./configure
bazel build --config=mkl -c opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package

OS version: Ubuntu Linux 14.04
Bazel version: 0.5.3

Error message:

ERROR: missing input file '//third_party/mkl:libmklml_intel.so'
ERROR: <path>/tensorflow/test/third_party/mkl/BUILD:16:1: //third_party/mkl:intel_binary_blob: missing input file '//third_party/mkl:libmklml_intel.so'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
ERROR: <path>/tensorflow/test/third_party/mkl/BUILD:16:1 1 input file(s) do not exist

The configure script is creating symlinks in third_party/mkl/ for libmkl_rt.so (see here), which is fine, but not for libmklml_intel.so (see here), which doesn't exist in the full MKL distribution. However third_party/mkl/BUILD references libmklml_intel.so. Is this a bug or is use of the full MKL library not supported in TensorFlow 1.3?

0 Kudos
3 Replies
Oleg_K_Intel1
Employee
1,341 Views

In file third_party/mkl/BUILD,

Could you replace libmklml.so to  libmkl_rt.so as follows:

cc_library(
    name = "intel_binary_blob",
    srcs = if_mkl([
        "@mkl//:libmklml_intel.so",
        "@mkl//:libiomp5.so",
    ]),
    visibility = ["//visibility:public"],
    deps = ["@mkl//:mkl_headers"],
)

Let us know if it helps,

Oleg

0 Kudos
Renshaw__Daniel
Beginner
1,341 Views

That fixed it, thanks!

For clarity, I changed

cc_library(
    name = "intel_binary_blob",
    srcs = if_mkl([
        "libdl.so.2",
        "libmklml_intel.so",
        "libiomp5.so",
    ]),
    includes = ["."],
    visibility = ["//visibility:public"],
)

to

cc_library(
    name = "intel_binary_blob",
    srcs = if_mkl([
        "libdl.so.2",
        "libmkl_rt.so",
        "libiomp5.so",
    ]),
    includes = ["."],
    visibility = ["//visibility:public"],
)

in the file third_party/mkl/BUILD.

I guess there needs to be some logic added to the configure process that alters that BUILD, or otherwise chooses between the two cc_library variants, automatically. However, with TensorFlow changing the way it does its build configuring, and possibly changing the way MKL is integrated, in the next version it's probably best to wait and see what TF r1.4 is like. I can manually alter the BUILD file for now.

0 Kudos
David_M_25
Beginner
1,341 Views

@Daniel, could you list your BUILD file again? You said you made a change in the cc_library section but I'm seeing the before and after in your post as identical. Thanks!

 

Edit: I see, it should be changed to:

cc_library(
    name = "intel_binary_blob",
    srcs = if_mkl([
        "libdl.so.2",
        "libmkl_rt.so",
        "libiomp5.so",
    ]),
    includes = ["."],
    visibility = ["//visibility:public"],
)

 

0 Kudos
Reply