TensorFlow:构建pip包时出错

时间:2017-03-29 14:03:02

标签: python tensorflow

我正在尝试从源代码构建TensorFlow。配置安装后,当我尝试使用以下命令构建到pip包时,

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

我收到以下错误消息:

ERROR: /workspace/tensorflow/core/BUILD:1312:1: Executing genrule //tensorflow/core:version_info_gen failed: bash failed: error executing command
(cd /root/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/execroot/workspace && \
exec env - \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; tensorflow/tools/git/gen_git_source.py --generate tensorflow/tools/git/gen
/spec.json tensorflow/tools/git/gen/head tensorflow/tools/git/gen/branch_ref "bazel-out/host/genfiles/tensorflow/core/util/version_info.cc"'): com.goo
gle.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Traceback (most recent call last):
File "tensorflow/tools/git/gen_git_source.py", line 260, in <module>
generate(args.generate)
File "tensorflow/tools/git/gen_git_source.py", line 212, in generate
git_version = get_git_version(data["path"])
File "tensorflow/tools/git/gen_git_source.py", line 152, in get_git_version
str("--work-tree=" + git_base_path), "describe", "--long", "--tags"
File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 8.567s, Critical Path: 7.90s

出了什么问题?

(Ubuntu 14.04,仅限CPU)

2 个答案:

答案 0 :(得分:1)

您的构建似乎在

中遇到错误
tensorflow/tools/git/gen_git_source.py

在第152行。在构建的这个阶段,脚本试图获取张量流回购的git版本号。你用git来检查你的张量流回购吗? / tensorflow / root目录中是否存在.git文件?也许你需要更新你的git版本?

类似于这个问题:Build Error Tensorflow

答案 1 :(得分:0)

即使我的:变量中有git,我也遇到了此错误。我从https://stackoverflow.com/a/5659249/212076得到了一个提示,即启动的子流程没有得到PATH变量。

解决方案是通过替换

PATH中的git命令进行硬编码
<ROOT>\tensorflow\tensorflow\tools\git\gen_git_source.py

val = bytes(subprocess.check_output([
        "git", str("--git-dir=%s/.git" % git_base_path),
        str("--work-tree=" + git_base_path), "describe", "--long", "--tags"
    ]).strip())

一旦修复,我又收到了另一个错误:val = bytes(subprocess.check_output([ "C:\Program Files (x86)\Git\cmd\git.cmd", str("--git-dir=%s/.git" % git_base_path), str("--work-tree=" + git_base_path), "describe", "--long", "--tags" ]).strip()) 。 我认为tensorflow根文件夹是应该被引用的文件夹,所以我编辑了fatal: Not a git repository: './.git'来替换

<ROOT>\tensorflow\tensorflow\tools\git\gen_git_source.py

git_version = get_git_version(".")

之后构建成功。

注意:与OP不同,我的构建平台是Windows 7 64位