使用共享对象(LIPTANSORFROUL.CC,so)失败的C++编译项目

使用共享对象(LIPTANSORFROUL.CC,so)失败的C++编译项目,c++,tensorflow,C++,Tensorflow,目前,在Tensorflow的支持下,我在编译和运行自己的大型项目时遇到了一些问题。在我自己的系统Ubuntu16.04 LTS上,一切正常。集群上的相同过程会导致编译错误,我还无法找到解决方案 系统信息 我是否编写了自定义代码:是 操作系统平台和发行版,例如Linux Ubuntu 16.04:CentOS 7.4.1708 TensorFlow从源代码或二进制代码安装:源代码使用git repo TensorFlow版本使用以下命令:1.9 Python版本:2.7.15 从源代码0.16编

目前,在Tensorflow的支持下,我在编译和运行自己的大型项目时遇到了一些问题。在我自己的系统Ubuntu16.04 LTS上,一切正常。集群上的相同过程会导致编译错误,我还无法找到解决方案

系统信息 我是否编写了自定义代码:是 操作系统平台和发行版,例如Linux Ubuntu 16.04:CentOS 7.4.1708 TensorFlow从源代码或二进制代码安装:源代码使用git repo TensorFlow版本使用以下命令:1.9 Python版本:2.7.15 从源代码0.16编译时的Bazel版本 从源代码7.30编译时的GCC/编译器版本 CUDA/cuDNN版本:未使用 GPU型号和内存:特斯拉K20m 要复制的确切命令:

从github克隆tensorflow回购 配置Bazel./tensorflow repo中的配置 建了libtensorflow_cc.so和bazel一起工作很好!!! 已下载的依赖项以及已交付的脚本tensorflow/contrib/makefile/download_dependencies.sh 也尝试过手动安装protobuf和eigen! 使用./autogen.sh&&./configure&&make&&make安装安装protobuf 从下载的依赖项安装了Eigen 已将库、标题和包含复制到自己的项目中:

$ cp bazel-bin/tensorflow/libtensorflow_cc.so ../tf_project/lib/
$ cp bazel-bin/tensorflow/libtensorflow_framework.so ../tf_project/lib/
$ cp /tmp/proto/lib/libprotobuf.a ../tf_project/lib/
$ mkdir -p ../tf_project/include/tensorflow
$ cp -r bazel-genfiles/ * ../tf_project/include/
$ cp -r tensorflow/cc ../tf_project/include/tensorflow
$ cp -r tensorflow/core ../tf_project/include/tensorflow
$ cp -r third_party ../tf_project/include
$ cp -r /tmp/proto/include/ * ../tf_project/include
$ cp -r /tmp/eigen/include/eigen3/ * ../tf_project/include
备注:在我自己的系统中,它以这种方式工作数周。我可以在自己的项目中使用tensorflow,在python项目中使用keras训练的导出模型。我使用客户端会话和tensorflow框架的许多其他功能进行预测,它工作正常

问题:在集群中,我可以将tensorflow编译为动态库,安装protobuf和Egeng。 当我试图编译我自己的系统的项目类似过程时,没有重大更改,它不起作用,并停止以下错误消息:

.../tensorflow/include/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
  ^~~~~
.../include/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
  ^~~~~
.../include/tensorflow/core/framework/tensor.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^~~~~
.../include/tensorflow/core/framework/tensor.pb.h:27:10: fatal error: google/protobuf/inlined_string_field.h: No such file or directory
 #include <google/protobuf/inlined_string_field.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
因此,显然这应该是一个问题:

此文件由与协议缓冲区标头不兼容的较新版本的protoc生成。请更新您的标题

致命错误:google/protobuf/inlined_string_field.h:没有这样的文件或目录

尝试过的解决方案:

我尝试了protobuf的不同版本,但每次尝试都有一个错误。 我尝试在没有下载_dependencies.sh脚本的情况下手动安装protobuf和eigen 我想知道,因为我自己的安装遵循完全相同的步骤正常工作。可能其中一个组件有问题,除非我尝试了不同的版本以确保这些不是新问题

有人能帮我解决这个错误,我可以在另一台机器上编译和运行这个项目吗

期待得到有用的解决方案:非常感谢您的支持


来自德国的问候

我以前遇到过这个问题,下面是我的解决方案:

我用bazel成功地构建了tensorflow-r1.8。我发现protoc的路径是3.5.0:

/home/zsb/.cache/bazel/_bazel_zsb/1372f28eb0671f692e7ac38330377d8c/execroot/org_tensorflow/bazel-out/host/bin/external/protobuf_archive/protoc --version
但实际上我的系统配置使用的是protoc版本3.4.0 我直接用原型版本确认了这一点


因此,最后我将系统protobuffer版本更新为3.5.0,解决了这个问题。

首先,我在github上检查了tensorflow r1.9要求protobuf>=3.6.0。使用download_dependencies.sh脚本,您总是得到protobuf 3.5.0,其中缺少内联的_string_field.h和一些其他头文件

其次,一些错误要求您更新protobuf版本。我也尝试过protobuf的许多版本。只有版本3.6.0运行良好,而不是版本3.6.1或更早的版本

对于这些错误

错误此文件是由更新版本的protoc生成的,它是

致命错误:google/protobuf/inlined_string_field.h:没有这样的文件或目录

这是一个版本不匹配的问题。我的解决方案是从

安装它并将cp/usr/local/include/google安装到某处/tf/include。它对我很有效。我不知道你是否试过3.6.0版

下载_dependencies.sh脚本将提供不匹配的 protobuf。请参阅我在github上发布的问题

另外,我注意到你复制的文件与我的不同。我是这样做的

sudo mkdir /usr/local/tensorflow/include
sudo cp -r tensorflow/contrib/makefile/downloads/eigen/Eigen /usr/local/tensorflow/include/
sudo cp -r tensorflow/contrib/makefile/downloads/eigen/unsupported /usr/local/tensorflow/include/
sudo cp -r tensorflow/contrib/makefile/gen/protobuf/include/google /usr/local/tensorflow/include/
sudo cp tensorflow/contrib/makefile/downloads/nsync/public/* /usr/local/tensorflow/include/
sudo cp -r bazel-genfiles/tensorflow /usr/local/tensorflow/include/
sudo cp -r tensorflow/cc /usr/local/tensorflow/include/tensorflow
sudo cp -r tensorflow/core /usr/local/tensorflow/include/tensorflow
sudo mkdir /usr/local/tensorflow/include/third_party
sudo cp -r third_party/eigen3 /usr/local/tensorflow/include/third_party/
sudo mkdir /usr/local/tensorflow/lib
sudo cp bazel-bin/tensorflow/libtensorflow_*.so /usr/local/tensorflow/lib
顺便说一句,我运行build_all_linux.sh而不是download_dependencies.sh


我希望这对你有帮助

即使你已经安装了protobuf系统也可能是从另一个地方获得的。检查您的路径以查看它使用的是哪种协议。谢谢您的评论。不幸的是,在这个系统中只有一个protobuf安装。这就是我在第5步之后安装的!谢谢你!我还需要跨sudo cp-r tensorflow/contrib/makefile/downloads/absl/usr/local/tensorflow/include进行复制