无法使用 bazel 运行 tensorflow

Unable to run tensorflow using bazel

我正在尝试 运行 在我 CPU 支持的 mac 中使用 Bazel 的 tensorflow mac。

我运行以下命令,

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

它抛出以下错误

ERROR: /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/core/BUILD:1323:1: no such target '//tensorflow/tools/git:gen/spec.json': target 'gen/spec.json' not declared in package 'tensorflow/tools/git' defined by /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'. ERROR: /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/core/BUILD:1323:1: no such target '//tensorflow/tools/git:gen/head': target 'gen/head' not declared in package 'tensorflow/tools/git' defined by /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'. ERROR: /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/core/BUILD:1323:1: no such target '//tensorflow/tools/git:gen/branch_ref': target 'gen/branch_ref' not declared in package 'tensorflow/tools/git' defined by /Users/Rocky/Downloads/Experiment/TensorFlow/tensorflow-master/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'. ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted.

我怎样才能解决这个问题?

(试图发表评论,但我没有足够的业力。然后将其发布为答案。)

错误消息告诉您构建规则引用了一个不存在的目标,或者该规则无权访问它。

以下命令的输出是什么? cd 进入 TensorFlow 项目的目录,那里有 WORKSPACE 文件,运行 从那里):

bazel query --output=build 'somepath("//tensorflow/core:version_info_gen",  "//tensorflow/tools/git:gen/spec.json")'

另外:

  • 您使用的是哪个版本的 Bazel?
  • 您检查了 TensorFlow 的哪个提交?
  • 您是否修改了源代码树中的任何内容?

我遇到了同样的问题,运行 以下命令为我解决了这个问题:

./configure

我使用了所有默认配置。查看此 issue 了解更多信息。