stillanoob
stillanoob

Reputation: 1379

TensorFlow : Error building pip package

I am trying to build TensorFlow from source. After configuring the installation, when I try to build to the pip package with the following command,

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

I get the following error message:

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

What's going wrong?

(Ubuntu 14.04, CPU only)

Upvotes: 0

Views: 703

Answers (2)

KalenGi
KalenGi

Reputation: 2077

I encountered this error even though I had git in my PATH variable. I got a hint from https://stackoverflow.com/a/5659249/212076 that the launched subprocess was not getting the PATH variable.

The solution was to hard-code the git command in <ROOT>\tensorflow\tensorflow\tools\git\gen_git_source.py by replacing

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

with

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

Once this got fixed I got another error: fatal: Not a git repository: './.git'. I figured the tensorflow root folder was the one that should have been referenced and so I edited <ROOT>\tensorflow\tensorflow\tools\git\gen_git_source.py to replace

git_version = get_git_version(".")

with

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

After that the build was successful.

NOTE: Unlike OP, my build platform was Windows 7 64 bit

Upvotes: 0

Montmorency
Montmorency

Reputation: 422

Your build appears to be encountering an error in

tensorflow/tools/git/gen_git_source.py

at line 152. At this stage in the build the script is trying to get the git version number of your tensor flow repo. Have you used git to check out your tensor flow repo? Are the .git files present in the /tensorflow/ root dir? Maybe you need to update your version of git?

Looks similar to this question: Build Error Tensorflow

Upvotes: 1

Related Questions