Jaehoon Kim
Jaehoon Kim

Reputation: 11

How to add tensorflow to existing bazel project as external dependencies

I have a c++ project (A) based on bazel build system using grpc and protobuf, and I want to add external dependency for tensorflow (//tensorflow:libtensorflow_cc.so) to my existing bazel project to use tensorflow c++ library in that project.

I have tried to add as git_repository(), but it did not work.

tail of project A's WORKSPACE

git_repository(
    name = "org_tensorflow",
    remote = "https://github.com/tensorflow/tensorflow.git",
    tag = "v1.3.0",
)

and the error message of bazel build

ERROR: /home/vvv/.cache/bazel/_bazel_irteam/41172dacf49e08aa58ebe872efb7e8d1/external/org_tensorflow/tensorflow/BUILD|446 col 1| error loading package '@
|| org_tensorflow//tensorflow/c': Extension file not found. Unable to load package for '@protobuf//:protobuf.bzl': The repository could not be resolved and referenced by '@ ||
org_tensorflow//tensorflow:libtensorflow_cc.so'^M || ERROR: Analysis of target '//inference:inf' failed; build aborted: error loading package '@org_tensorflow//tensorflow/c': Extension file not found. Unable to load package for '@ || protobuf//:protobuf.bzl': The repository could not be resolved^M

How to add external dependency for tensorflow?

Upvotes: 1

Views: 1484

Answers (1)

hlopko
hlopko

Reputation: 3270

You can mimic what tensorflow/serving is doing, they access tensorflow as a git submodule and make it work with bazel smoothly.

Upvotes: 1

Related Questions