bazel: Error occurred when trying to build with precompiled library on macOS
Description of the problem / feature request:
I’m trying to build the TensorFlow with Intel MKL on macOS, which depends on a precompiled library Intel MKL. The building process failed, and it told dyld: Library not loaded: @rpath/libmklml.dylib
, which is the mentioned third party library. I’ve set the rule according to the document as following shows:
# third_party/mkl/BUILD
cc_library(
name = "intel_binary_blob",
srcs = [
"@mkl//:libmklml",
"@mkl//:libiomp5",
],
hdrs = ["@mkl//:mkl_headers"],
strip_include_prefix = "/external/mkl/include",
visibility = ["//visibility:public"],
)
where mkl_headers
, libmklml
and libimp5
are respectively:
# third_party/mkl/mkl.BUILD
# Note: This file will be symbol linked to the downloaded position
filegroup(
name = "mkl_headers",
srcs = glob(["include/*"]),
visibility = ["//visibility:public"],
)
load("@org_tensorflow//tensorflow:tensorflow.bzl",
"if_darwin",
"if_linux_x86_64")
filegroup(
name = "libmklml",
srcs = if_darwin(["lib/libmklml.dylib"])
+ if_linux_x86_64(["lib/libmklml_intel.so"]),
visibility = ["//visibility:public"],
)
filegroup(
name = "libiomp5",
srcs = if_darwin(["lib/libiomp5.dylib"])
+ if_linux_x86_64(["lib/libiomp5.so"]),
visibility = ["//visibility:public"],
)
However, this building procedure can work on Linux. Considering the constraint of SIP on macOS, I’ve replaced the compiler with latest llvm installed with HomeBrew, and default Python too with the HomeBrew’s version, but they seemed to be useless.
Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Error log:
dyld: Library not loaded: @rpath/libmklml.dylib
Referenced from: /private/var/tmp/_bazel_shilei/fe2ffd3189bc27eabf3757c054a2a694/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/gen_parsing_ops_py_wrappers_cc
Reason: image not found
The easiest way to reproduce the problem is to execute the following command on macOS:
bazel build --copt=-DINTEL_MKL_DNN --config=mkl -c opt //tensorflow/tools/pip_package:build_pip_package
What operating system are you running Bazel on?
macOS 10.13.13
What’s the output of bazel info release
?
release 0.11.0-homebrew
If bazel info release
returns “development version” or “(@non-git)”, tell us how you built Bazel.
brew install bazel
Have you found anything relevant by searching the web?
Nope.
Any other information, logs, or outputs that you want to share?
ERROR: tensorflow/tensorflow/python/BUILD:1429:1: Executing genrule //tensorflow/python:parsing_ops_pygenrule failed (Aborted): bash failed: error executing command /bin/bash bazel-out/darwin-py3-opt/genfiles/tensorflow/python/parsing_ops_pygenrule.genrule_script.sh
dyld: Library not loaded: @rpath/libmklml.dylib
Referenced from: /private/var/tmp/_bazel_shilei/fe2ffd3189bc27eabf3757c054a2a694/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/gen_parsing_ops_py_wrappers_cc
Reason: image not found
bazel-out/darwin-py3-opt/genfiles/tensorflow/python/parsing_ops_pygenrule.genrule_script.sh: line 2: 21161 Abort trap: 6
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
Commits related to this issue
- Example project for Bazel issue #4794 See https://github.com/bazelbuild/bazel/issues/4794 — committed to laszlocsomor/projects by laszlocsomor 6 years ago
- Example project for Bazel issue #4794 See https://github.com/bazelbuild/bazel/issues/4794 — committed to laszlocsomor/projects by laszlocsomor 6 years ago
- Example project for Bazel issue #4794 See https://github.com/bazelbuild/bazel/issues/4794 — committed to laszlocsomor/projects by laszlocsomor 6 years ago
- Example project for Bazel issue #4794 See https://github.com/bazelbuild/bazel/issues/4794 — committed to laszlocsomor/projects by laszlocsomor 6 years ago
Hi @laszlocsomor @mhlopko I noticed that the version of 0.12 has been released, and I’ve taken a try. The good news is that bazel 0.12 seems to fix the issue of @rpath on macOS. Our project could be built with the latest release.