无法在win7下使用bazel编译和运行基本张量流c示例(tensorflow(GPU或CPU)已经可以正常使用keras(python3)) . 也许重要的是要知道我在代理服务器后面操作(pip,pacman使用http_proxy环境变量,bazel也是这样) .

对我来说,似乎无法应用补丁:(见下文)“找不到要在输入行4处修补的文件” .

我该怎么做才能完成解决方案? (避免补丁,手动应用,下载更新版本....)

我该怎么做来检查错误/获取更多细节?

我是否需要(重新)从源安装tensorflow以运行c示例?

相关链接

正如我所见,我不能发布超过2个链接,所以我描述了主题,我会尝试并会给出反馈,如果有帮助...

prot_library / WORKSPACE:github cgrushko proto_library工作区

stackoverflow:protobuf c编译器的bazel规则

博客bazel build carmi grushko“proto_library是一种与语言无关的规则”

stackoverflow:找不到包google protobuf

stackoverflow:没有包rptobuf开发可用错误

stackoverflow:tensorflow bazel build失败 - 没有这样的包'@ protobuf //'

stackoverflow:protobuf c编译器的bazel规则

stackoverflow:tensorflow buld错误与bazel

stackoverflow:tensorflow bazel build下降

系统信息

操作系统:win7-64

VS2015

JDK8

Tensorflow在win7下通过python3(带GPU)从二进制(pip3 install ....)版本安装:'1.0.1'

Bazel版本:构建标签:0.5.2-(@ non-git)

protobuf安装在python3.5中:

$ pip install protobuf --proxy="http://proxy.com:8080"
 Requirement already satisfied: protobuf in d:\bin\python64-3-anaconda\envs\python64-35\lib\site-packages
 Requirement already satisfied: six>=1.9 in d:\bin\python64-3-anaconda\envs\python64-35\lib\site-packages (from protobuf)
 Requirement already satisfied: setuptools in d:\bin\python64-3-anaconda\envs\python64-35\lib\site-packages\setuptools-27.2.0-py3.5.egg (from protobuf)

安装补丁:(msys2)$ patch --version - > GNU补丁2.7.5

我没有任何原型......(有些网站提到它,但pacman和pip都不知道)

描述问题

当我尝试构建一个包含tensorflow的简单脚本时会出现问题https://www.tensorflow.org/api_guides/cc/guide

使用msys2在...中运行bazel / Sourcen / external / tensorflow-master /

$ bazel run -c opt // tensorflow / cc / example1:example-out

WARNING: ignoring http_proxy in environment.
WARNING: C:/tools/msys64/tmp/_bazel_xxxxxx/6esgz-yl/external/bazel_tools/tools/cpp/cc_configure.bzl:67:3:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.

WARNING: C:/tools/msys64/tmp/_bazel_xxxxxxx/6esgz-yl/external/bazel_tools/tools/cpp/cc_configure.bzl:67: 3:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables,eg. VS140COMNTOOLS.

WARNING: C:/tools/msys64/tmp/_bazel_xxxxxxxx/6esgz-yl/external/bazel_tools/tools/cpp/cc_configure.bzl:67:3:
Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC.

ERROR: xxxxxx...../tensorflow-master/tensorflow/cc/example1/BUILD:1:1: error loading package 'tensorflow/core': Encountered error while reading extension file 'protobuf.bzl': no such package '@protobuf//': Traceback (most recent call last):

File "xxxxxxxx.../tensorflow-master/tensorflow/workspace.bzl", line 116 _apply_patch(repo_ctx, repo_ctx.attr.patch_file)

File "xxxxx..../tensorflow-master/tensorflow/workspace.bzl", line 107, in _apply_patch _execute_and_check_ret_code(repo_ctx, cmd)

File "xxxxx..../tensorflow-master/tensorflow/workspace.bzl", line 91, in _execute_and_check_ret_code

fail("Non-zero return code({1}) when ..., <2 more arguments>))

Non-zero return code(1) when executing 'c:/tools/msys64/usr/bin/bash.exe -c patch -p1 -d C:/tools/msys64/tmp/_bazel_xxxxx/6esgz-yl/external/protobuf -i xxxxx..../tensorflow-master/third_party/protobuf/add_noinlines.patch':

Stdout: can't find file to patch at input line 4

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

........................................

|diff -u -r a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
|--- a/src/google/protobuf/compiler/cpp/cpp_file.cc 2017-02-10 23:55:34.000000000 +0100
|+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc 2017-03-21 13:41:46.931979154 +0100

..................................

File to patch:
Skip this patch? [y]
Skipping patch.
3 out of 3 hunks ignored

 Stderr: and referenced by '//tensorflow/cc/example1:example-out'.
 ERROR: Analysis of target '//tensorflow/cc/example1:example-out' failed; 

 build aborted.

 INFO: Elapsed time: 9,402s
 ERROR: Build failed. Not running target.

源代码/日志

为了更好地理解问题,我更改了名称或原始文件和目录

目录... / Sourcen / external / tensorflow-master / tensorflow / cc / example1 /包含3个文件:

  • WORKSPACE

  • BUILD

  • example-code.cc

..... WORKSPACE ........空

...... Build

cc_binary(
name = "example-out",
srcs = ["example-code.cc"],
 deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
 "//tensorflow/core:tensorflow",
],
)

...................................

............ example-code.cc

// tensorflow/cc/example/example.cc
#include "tensorflow/cc/client/client_session.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/tensor.h"

int main() {
  using namespace tensorflow;
  using namespace tensorflow::ops;
  Scope root = Scope::NewRootScope();
  // Matrix A = [3 2; -1 0]
  auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f}});
  // Vector b = [3 5]
  auto b = Const(root, { {3.f, 5.f}});
  // v = Ab^T
  auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true));
  std::vector outputs;
  ClientSession session(root);
  // Run and fetch v
  TF_CHECK_OK(session.Run({v}, &outputs));
  // Expect outputs[0] == [19; -3]
  LOG(INFO) << outputs[0].matrix();
return 0;
}

..............