首页 文章

使用Bazel构建Tensorflow失败(Ubuntu 18.04,Cuda 9.1)

提问于
浏览
0

我试图跟随this tutorial用Cuda 9.1安装tensorflow,但是当我运行以下命令时......

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

...经过长时间的编译后,我收到了这个错误

INFO: From Compiling tensorflow/core/grappler/clusters/virtual_cluster.cc:
In file included from ./tensorflow/core/framework/common_shape_fns.h:22:0,
                 from ./tensorflow/core/framework/resource_mgr.h:24,
                 from ./tensorflow/core/common_runtime/device.h:43,
                 from ./tensorflow/core/common_runtime/device_set.h:23,
                 from ./tensorflow/core/grappler/clusters/virtual_cluster.h:21,
                 from tensorflow/core/grappler/clusters/virtual_cluster.cc:16:
./tensorflow/core/util/tensor_format.h: In function 'tensorflow::TensorShape tensorflow::ShapeFromFormat(tensorflow::TensorFormat, tensorflow::int64, tensorflow::gtl::ArraySlice<long long int>, tensorflow::int64)':
./tensorflow/core/util/tensor_format.h:501:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (format == FORMAT_NHWC_VECT_W && dim == spatial.size() - 1) {
                                         ~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from ./tensorflow/core/platform/default/logging.h:24:0,
                 from ./tensorflow/core/platform/logging.h:25,
                 from ./tensorflow/core/lib/core/refcount.h:22,
                 from ./tensorflow/core/platform/tensor_coding.h:21,
                 from ./tensorflow/core/framework/resource_handle.h:19,
                 from ./tensorflow/core/framework/allocator.h:24,
                 from ./tensorflow/core/common_runtime/device.h:35,
                 from ./tensorflow/core/common_runtime/device_set.h:23,
                 from ./tensorflow/core/grappler/clusters/virtual_cluster.h:21,
                 from tensorflow/core/grappler/clusters/virtual_cluster.cc:16:
./tensorflow/core/util/tensor_format.h: In instantiation of 'T tensorflow::GetTensorDim(tensorflow::gtl::ArraySlice<T>, tensorflow::TensorFormat, char) [with T = long long int; tensorflow::gtl::ArraySlice<T> = absl::Span<const long long int>]':
./tensorflow/core/util/tensor_format.h:452:47:   required from here
./tensorflow/core/util/tensor_format.h:420:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   CHECK(index >= 0 && index < dimension_attributes.size())

./tensorflow/core/platform/macros.h:87:47: note: in definition of macro 'TF_PREDICT_FALSE'
 #define TF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
                                               ^
./tensorflow/core/util/tensor_format.h:420:3: note: in expansion of macro 'CHECK'
   CHECK(index >= 0 && index < dimension_attributes.size())
   ^
./tensorflow/core/util/tensor_format.h: In instantiation of 'T tensorflow::GetFilterDim(tensorflow::gtl::ArraySlice<T>, tensorflow::FilterTensorFormat, char) [with T = long long int; tensorflow::gtl::ArraySlice<T> = absl::Span<const long long int>]':
./tensorflow/core/util/tensor_format.h:461:54:   required from here
./tensorflow/core/util/tensor_format.h:435:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   CHECK(index >= 0 && index < dimension_attribute.size())

./tensorflow/core/platform/macros.h:87:47: note: in definition of macro 'TF_PREDICT_FALSE'
 #define TF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
                                               ^
./tensorflow/core/util/tensor_format.h:435:3: note: in expansion of macro 'CHECK'
   CHECK(index >= 0 && index < dimension_attribute.size())
   ^
ERROR: /usr/lib/x86_64-linux-gnu/tensorflow/tensorflow/contrib/nccl/BUILD:24:1: error while parsing .d file: /home/mounir/.cache/bazel/_bazel_mounir/d313cf0d9cbad5990e55f24fb423f009/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/contrib/nccl/_objs/python/ops/_nccl_ops_gpu/nccl_ops.pic.d (No such file or directory)
In file included from ./tensorflow/core/framework/variant.h:26:0,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:33:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:34:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:35:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/lib/core/status.h:23:0,
                 from ./tensorflow/core/framework/variant.h:29,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_kernel.h:27:0,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:33:0,
                 from ./tensorflow/core/framework/op_kernel.h:27,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_def_builder.h:24:0,
                 from ./tensorflow/core/framework/op.h:23,
                 from ./tensorflow/core/framework/op_kernel.h:30,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_def_util.h:23:0,
                 from ./tensorflow/core/framework/op.h:24,
                 from ./tensorflow/core/framework/op_kernel.h:30,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1904.904s, Critical Path: 126.88s
INFO: 3547 processes: 3547 local.
FAILED: Build did NOT complete successfully

My system setup is as follows :

  • Nvidia驱动程序版本390

  • Ubuntu 18.04

  • GPU Nvidia P400 Quadro(计算能力6.1)

  • Cuda 9.1

  • Cudnn 7.1.3

  • NCCL 2.1.15

EDIT : 将protobuf更新为3.6.1后:

pip install protobuf

问题仍然出现:

ERROR: /home/mounir/tensorflow/tensorflow/contrib/nccl/BUILD:24:1: error while parsing .d file: /home/mounir/.cache/bazel/_bazel_mounir/84217cc82dae4826232c875306f45ef9/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/contrib/nccl/_objs/python/ops/_nccl_ops_gpu/nccl_ops.pic.d (No such file or directory)
In file included from ./tensorflow/core/framework/variant.h:26:0,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:33:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/resource_handle.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:34:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/tensor.pb.h:35:0,
                 from ./tensorflow/core/framework/variant.h:26,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/types.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/lib/core/status.h:23:0,
                 from ./tensorflow/core/framework/variant.h:29,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:20,
                 from ./tensorflow/core/framework/log_memory.h:19,
                 from ./tensorflow/core/common_runtime/gpu/gpu_event_mgr.h:21,
                 from ./tensorflow/contrib/nccl/kernels/nccl_manager.h:31,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:21:
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/lib/core/error_codes.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_kernel.h:27:0,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from bazel-out/k8-opt/genfiles/tensorflow/core/framework/kernel_def.pb.h:33:0,
                 from ./tensorflow/core/framework/op_kernel.h:27,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/attr_value.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_def_builder.h:24:0,
                 from ./tensorflow/core/framework/op.h:23,
                 from ./tensorflow/core/framework/op_kernel.h:30,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/op_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
In file included from ./tensorflow/core/framework/op_def_util.h:23:0,
                 from ./tensorflow/core/framework/op.h:24,
                 from ./tensorflow/core/framework/op_kernel.h:30,
                 from tensorflow/contrib/nccl/kernels/nccl_ops.cc:22:
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^~~~~
bazel-out/k8-opt/genfiles/tensorflow/core/framework/api_def.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1294.361s, Critical Path: 71.52s
INFO: 4743 processes: 4743 local.
FAILED: Build did NOT complete successfully

3 回答

  • 0

    TensorFlow需要最新版本的protobuf . 你有可能有一个早于3.6.0的protobuf版本?你能将系统上的protobuf版本更新到最新版本(3.6.1),运行 bazel clean ,重新配置和重建tensorflow吗?

  • 0

    我遇到了和你一样的问题 . 我尝试了很多版本的protobuf,包括旧版本和最新版本3.6.1 . 但是,只有版本3.6.0运行良好 .

    也许你可以尝试protobuf版本3.6.0,我希望它适合你 .

    顺便说一下,你正在编译tensorflow C,你需要下载protobuf_cpp_3.6.0.zip而不是安装它使用pip install protobuf

    https://github.com/protocolbuffers/protobuf/releases/download/v3.6.0/protobuf-cpp-3.6.0.zip

  • 0

    将protobuf更新到版本3.6.1不会对tensorflow安装/编译产生影响 . 使用Bazel完成tensorflow的编译,下载Protobuf的源代码(撰写时为3.6.0) .

    使用3.6.1编译tensorflow的一种方法是编辑tensorflow / tensorflow /目录中的workspace.bzl文件 . 您需要更改以下部分:

    diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
    index 8e6f414..1493789 100755
    --- a/tensorflow/workspace.bzl
    +++ b/tensorflow/workspace.bzl
    @@ -366,11 +366,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
         )
    
         PROTOBUF_URLS = [
    -        "https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
    -        "https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
    +        "https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.1.tar.gz",
    +        "https://github.com/google/protobuf/archive/v3.6.1.tar.gz",
         ]
    -    PROTOBUF_SHA256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4"
    -    PROTOBUF_STRIP_PREFIX = "protobuf-3.6.0"
    +    PROTOBUF_SHA256 = "3d4e589d81b2006ca603c1ab712c9715a76227293032d05b26fca603f90b3f5b"
    +    PROTOBUF_STRIP_PREFIX = "protobuf-3.6.1"
    
         tf_http_archive(
             name = "protobuf_archive",
    

    通过这样做,您正在更改Bazel用于编译Tensorflow和生成.pb.h文件的protobuf版本 .

相关问题