【问题标题】:TensorFlow : Error building pip packageTensorFlow:构建 pip 包时出错
【发布时间】:2017-08-23 01:49:22
【问题描述】:

我正在尝试从源代码构建 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)

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

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

    解决方案是通过替换来硬编码&lt;ROOT&gt;\tensorflow\tensorflow\tools\git\gen_git_source.py 中的git 命令

    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())
    

    一旦这个问题得到解决,我又遇到了另一个错误:fatal: Not a git repository: './.git'。 我认为 tensorflow 根文件夹是应该被引用的,所以我编辑了 &lt;ROOT&gt;\tensorflow\tensorflow\tools\git\gen_git_source.py 来替换

    git_version = get_git_version(".")
    

    git_version = get_git_version("../../../../")
    

    之后构建成功。

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

    【讨论】:

      【解决方案2】:

      您的构建似乎在

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

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

      看起来类似于这个问题:Build Error Tensorflow

      【讨论】:

      • 在 docker 容器中运行 tensorflow,但它没有 git。安装了 git,它现在可以工作了。谢谢。
      猜你喜欢
      • 1970-01-01
      • 2017-10-22
      • 2020-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-21
      • 1970-01-01
      相关资源
      最近更新 更多