python - Nested Bazel Projects -
i'm trying build project uses tensorflow serving, made directory my_dir workspace file, cloned serving repo it, put custom files directory my_project, configured tensorflow within tensorflow_serving, built tensorflow serving my_dir/serving with
bazel build //tensorflow_serving/...
everything builds fine there, try build python file imitating mnist_export , put in my_dir , make build file
py_binary( name = "export_cnn", srcs = [ "export_cnn.py", ], deps = [ "@tf//tensorflow:tensorflow_py", "@tf_serving//tensorflow_serving/session_bundle:exporter", ], )
however, when run
bazel build //my_project:export_cnn
i following errors:
error: .../bazel/_bazel_me/3ef3308a843af155635e839105e8da5c/external/tf/tensorflow/core/build:92:1: null failed: protoc failed: error executing command bazel-out/host/bin/external/tf/google/protobuf/protoc '--cpp_out=bazel-out/local_linux-fastbuild/genfiles/external/tf' -iexternal/tf -iexternal/tf/google/protobuf/src ... (remaining 1 argument(s) skipped). tensorflow/core/framework/step_stats.proto: file not found. tensorflow/core/framework/device_attributes.proto: file not found. tensorflow/core/framework/graph.proto: file not found. tensorflow/core/framework/tensor.proto: file not found. tensorflow/core/protobuf/config.proto: file not found. tensorflow/core/protobuf/worker.proto: import "tensorflow/core/framework/step_stats.proto" not found or had errors. tensorflow/core/protobuf/worker.proto: import "tensorflow/core/framework/device_attributes.proto" not found or had errors. tensorflow/core/protobuf/worker.proto: import "tensorflow/core/framework/graph.proto" not found or had errors. tensorflow/core/protobuf/worker.proto: import "tensorflow/core/framework/tensor.proto" not found or had errors. tensorflow/core/protobuf/worker.proto: import "tensorflow/core/protobuf/config.proto" not found or had errors. tensorflow/core/protobuf/worker.proto:41:12: "deviceattributes" not defined. tensorflow/core/protobuf/worker.proto:64:3: "graphdef" not defined. tensorflow/core/protobuf/worker.proto:72:3: "graphoptions" not defined. tensorflow/core/protobuf/worker.proto:141:3: "tensorproto" not defined. tensorflow/core/protobuf/worker.proto:180:3: "stepstats" not defined. tensorflow/core/protobuf/worker.proto:225:3: "busadjacency" not defined. tensorflow/core/protobuf/worker.proto:227:3: "busadjacency" not defined. tensorflow/core/protobuf/worker.proto:232:3: "tensorproto" not defined. tensorflow/core/protobuf/worker.proto:272:3: "stepstats" not defined.
in workspace file, have following:
local_repository( name = "tf", path = __workspace_dir__ + "/serving/tensorflow", ) local_repository( name = "tf_serving", path = __workspace_dir__ + "/serving", ) load('//serving/tensorflow/tensorflow:workspace.bzl', 'tf_workspace') tf_workspace("serving/tensorflow/", "@tf")
my hypothesis because tensorflow sub-sub-project not putting generated files in grandparent-projects bazel-out. however, i've tried many things , haven't been able work.
i have tensorflow serving in folder , project in another. workspace file:
workspace(name = "my_project") local_repository( name = "org_tensorflow", path = __workspace_dir__ + "/tf-serving/tensorflow/", ) local_repository( name = "tf_serving", path = __workspace_dir__ + "/tf-serving/", ) load('//tf-serving/tensorflow/tensorflow:workspace.bzl', 'tf_workspace') tf_workspace("tf-serving/tensorflow/", "@org_tensorflow") # ===== grpc dependencies ===== bind( name = "libssl", actual = "@boringssl_git//:ssl", ) bind( name = "zlib", actual = "@zlib_archive//:zlib", )
i have copied zlib.build tensorflow serving same place have workspace file.
the build file in project has rule (similar yours):
py_binary( name = "export_model", srcs = [ "export_model.py", ], deps = [ "@org_tensorflow//tensorflow:tensorflow_py", "@tf_serving//tensorflow_serving/session_bundle:exporter", ], )
the difference between code , yours included dependencies in root workspace. code compiling , working fine me in 1 machine have issues compile in others (ubuntu 14.04) because of 1 dependency. hope works you.