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

Fix MPI build issue with bazel #20147

Merged
merged 3 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorflow/contrib/mpi_collectives/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ tf_custom_op_library(
deps = [
":mpi_defines",
":mpi_message_proto_cc",
"//tensorflow/stream_executor:stream_executor_headers_lib",
"//third_party/mpi",
],
)
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/mpi_collectives/kernels/mpi_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ limitations under the License.
*/

template <class T>
using StatusOr = se::port::StatusOr<T>;
using StatusOr = stream_executor::port::StatusOr<T>;

using CPUDevice = Eigen::ThreadPoolDevice;
using GPUDevice = Eigen::GpuDevice;
Expand Down
9 changes: 9 additions & 0 deletions tensorflow/stream_executor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ licenses(["restricted"])

load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda_is_configured")
load("//tensorflow/core:platform/default/build_config_root.bzl", "if_static")
load("//tensorflow:tensorflow.bzl", "cc_header_only_library")

STREAM_EXECUTOR_HEADERS = glob([
"*.h",
Expand Down Expand Up @@ -51,6 +52,14 @@ cc_library(
] + if_static([":stream_executor_impl"]),
)

cc_header_only_library(
name = "stream_executor_headers_lib",
visibility = ["//visibility:public"],
deps = [
":stream_executor",
],
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem is this new build rule solving? I thought this was the purpose of //tensorflow/core:stream_executor_headers_lib.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlebar Without the headers_lib, the following error will show up:

ERROR: /home/ubuntu/tensorflow/tensorflow/contrib/mpi_collectives/BUILD:40:1: undeclared inclusion(s) in rule '//tensorflow/contrib/mpi_collectives:python/ops/_mpi_ops.so':
this rule is missing dependency declarations for the following files included by 'tensorflow/contrib/mpi_collectives/kernels/mpi_ops.cc':
  'tensorflow/stream_executor/lib/statusor.h'
  'tensorflow/stream_executor/lib/status.h'
  'tensorflow/stream_executor/lib/error.h'
  'tensorflow/stream_executor/lib/stringpiece.h'
  'tensorflow/stream_executor/platform/port.h'
  'tensorflow/stream_executor/platform/logging.h'
  'tensorflow/stream_executor/lib/statusor_internals.h'
Target //tensorflow/tools/pip_package:build_pip_package failed to build

So I added the stream_executor_headers_lib to address the above undeclared inclusion(s) issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the headers_lib, the following error will show up:

That explains why you need to add a new dependency to tensorflow/contrib/mpi_collectives/BUILD.

My question is, can that dependency be //tensorflow/core:stream_executor_headers_lib instead of this new rule? If not, why not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlebar With //tensorflow/core:stream_executor_headers_lib the following error will show up:

ERROR: /home/ubuntu/tensorflow/tensorflow/contrib/mpi_collectives/BUILD:40:1: Label '//tensorflow/core:stream_executor_headers_lib' is duplicated in the 'deps' attribute of rule 'python/ops/_mpi_ops_gpu'
ERROR: /home/ubuntu/tensorflow/tensorflow/contrib/mpi_collectives/BUILD:40:1: Label '//tensorflow/core:stream_executor_headers_lib' is duplicated in the 'deps' attribute of rule 'python/ops/_mpi_ops.so_check_deps'
ERROR: /home/ubuntu/tensorflow/tensorflow/contrib/mpi_collectives/BUILD:40:1: Label '//tensorflow/core:stream_executor_headers_lib' is duplicated in the 'deps' attribute of rule 'python/ops/_mpi_ops.so'

I am not sure about the error, though from _mpi_ops_gpu I guess stream_executor may have gpu and no-gpu version and that might be the conflict?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, indeed, tensorflow/core:stream_executor_headers_lib depends on CUDA stuff. So the new build rule you added is different in this important way.

These build rules are extremely messed up.

I'm happy to take this for now, with the caveat that if and when we clean up the SE build rules, we may break you again. I don't like that, but apparently we have no continuous builds for MPI. :-/


cc_library(
name = "cuda_platform",
srcs = if_cuda_is_configured(
Expand Down