Reputation: 9346
I'm trying to modify this tutorial for compiling a TensorFlow network for use with C++. It currently requires you to copy your network file into the TensorFlow source code so the dependencies can be found, but I'd rather not do that. Note that TensorFlow is also built with Bazel.
Here is my BUILD
file:
cc_binary(
name = "mnistpredict_keras",
srcs = ["mnist_keras.cc", "MNIST.h"],
deps = [
"//tensorflow/core:tensorflow",
],
)
When I try to run $ bazel build :mnistpredict_keras
I get the error:
ERROR: /home/saubin/git/tf-keras-speed-test/loadgraph/BUILD:17:1: no such package 'tensorflow/core': BUILD file not found on package path and referenced by '//:mnistpredict_keras'.
ERROR: Analysis of target '//:mnistpredict_keras' failed; build aborted.
INFO: Elapsed time: 0.105s
Obviously, the problem is I'm trying to compile something in my folder ~/git/tf-keras-speed-test/loadgraph
but it can't find the dependency //tensorflow/core:tensorflow
. How do I properly give the path to the dependency? The documentation for deps
appears to be non-existent.
Adding a local_repository
to my WORKSPACE
:
local_repository(
name = "tensorflow",
path = "/home/saubin/src/tensorflow",
)
This changed nothing.
Trying to pass the full path:
cc_binary(
name = "mnistpredict_keras",
srcs = ["mnist_keras.cc", "MNIST.h"],
deps = [
"/home/saubin/src/tensorflow/tensorflow/core:tensorflow",
],
)
But I get the same error:
ERROR: /home/saubin/git/tf-keras-speed-test/loadgraph/BUILD:17:1: no such package 'tensorflow/core': BUILD file not found on package path and referenced by '//:mnistpredict_keras'.
ERROR: Analysis of target '//:mnistpredict_keras' failed; build aborted.
INFO: Elapsed time: 0.287s
Mark TensorFlow as an external repository dependency:
cc_binary(
name = "mnistpredict_keras",
srcs = ["mnist_keras.cc", "MNIST.h"],
deps = [
"@tensorflow//tensorflow/core:tensorflow",
],
)
But this gives me this error:
WARNING: /home/saubin/.cache/bazel/_bazel_saubin/74f664e7cf53364557da8b57a716c919/external/tensorflow/WORKSPACE:1: Workspace name in /home/saubin/.cache/bazel/_bazel_saubin/74f664e7cf53364557da8b57a716c919/external/tensorflow/WORKSPACE (@org_tensorflow) does not match the name given in the repository's definition (@tensorflow); this will cause a build error in future versions.
ERROR: /home/saubin/git/tensorgraph/loadgraph/BUILD:1:1: error loading package '@tensorflow//tensorflow/core': Encountered error while reading extension file 'sycl/build_defs.bzl': no such package '@local_config_sycl//sycl': error loading package 'external': The repository named 'local_config_sycl' could not be resolved and referenced by '//:mnistpredict'.
ERROR: Analysis of target '//:mnistpredict' failed; build aborted.
INFO: Elapsed time: 0.326s
Upvotes: 2
Views: 4298
Reputation: 1805
The documentation for external dependencies is https://bazel.build/versions/master/docs/external.html.
The syntax that you are looking for is @tensorflow//tensorflow/core:tensorflow
.
Labels that start with //
refer to the current repository. Labels that start with @reponame//
refer to the reponame repository.
Upvotes: 2