编译失败&在win7下使用bazel运行basic tensorflow 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规则
blog bazel build carmi grushko" proto_library是一个与语言无关的规则"
stackoverflow:找不到包google protobuf
stackoverflow:没有包rptobuf开发可用错误
stackoverflow:tensorflow bazel build failed - 没有这样的软件包' @protobuf //'
stackoverflow:protobuf c ++编译器的bazel规则
stackoverflow:使用bazel
的tensorflow buld错误stackoverflow:tensorflow bazel build falling
操作系统:win7-64
VS2015
JDK8
通过python3(带GPU)从二进制(pip3 install ....)版本安装在win7下的Tensorflow:' 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.
为了更好地理解问题,我更改了名称或原始文件&amp;目录
目录... / Sourcen / external / tensorflow-master / tensorflow / cc / example1 /包含3个文件:
..... WORKSPACE ........空
......建立
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;
}
..............