zoukankan      html  css  js  c++  java
  • 一个简单操作解决protobuf版本问题,复制粘贴你会吧

    • 这个方法虽然简单,但是我们有完美的利用anaconda的解决方案,能够解决服务器上大家版本冲突,你想要几个环境就可以建立几个完全不冲突的环境,算是一本万利,教程在http://www.cnblogs.com/SweetBeens/p/8650460.html,推荐用这种方法。当然docker更好一些,但是老代码是没有docker文件的。
    • 从头说起:

    如何看你的需要安装的版本呢,上图:

    注意看我的文件的路径,这就是caffe官网上的那句命令行出处:

    for req in $(cat requirements.txt); do pip install $req; done

    鉴于我用的是segnet作者自己改的python版本的caffe,所以这是我的目录,你可以穷搜,然后自己挑一个看看需要安装什么。按理说照着我这个txt,不论我什么版本的都该好使,但是没准我的txt找的不对,或者protobuf不向后兼容了,或者caffe找的anaconda的protobuf,版本有问题,总之我越来越想看有没有caffe配置更详细的官方原文doc,或者我应该看看linux from scrach。这种盲人摸象式解决问题损失了很多乐趣。

    •  我现在开始折腾我们实验室的服务器,里面的protobuf版本比较高,所以我要用2.6.1的,我首先用下面连接的方法安装了2.6.1:(你可以选择跳过到最后开始解决,那是正题)

    http://blog.csdn.net/whoamiyang/article/details/52947225

    • 以下是提示我的路经:
    libtool: install: (cd /usr/local/lib && { ln -s -f libprotoc.so.9.0.1 libprotoc.so.9 || { rm -f libprotoc.so.9 && ln -s libprotoc.so.9.0.1 libprotoc.so.9; }; })
    libtool: install: (cd /usr/local/lib && { ln -s -f libprotoc.so.9.0.1 libprotoc.so || { rm -f libprotoc.so && ln -s libprotoc.so.9.0.1 libprotoc.so; }; })
    libtool: install: /usr/bin/install -c .libs/libprotoc.lai /usr/local/lib/libprotoc.la
    libtool: install: /usr/bin/install -c .libs/libprotobuf-lite.a /usr/local/lib/libprotobuf-lite.a
    libtool: install: chmod 644 /usr/local/lib/libprotobuf-lite.a
    libtool: install: ranlib /usr/local/lib/libprotobuf-lite.a
    libtool: install: /usr/bin/install -c .libs/libprotobuf.a /usr/local/lib/libprotobuf.a
    libtool: install: chmod 644 /usr/local/lib/libprotobuf.a
    libtool: install: ranlib /usr/local/lib/libprotobuf.a
    libtool: install: /usr/bin/install -c .libs/libprotoc.a /usr/local/lib/libprotoc.a
    libtool: install: chmod 644 /usr/local/lib/libprotoc.a
    libtool: install: ranlib /usr/local/lib/libprotoc.a
    libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
    ----------------------------------------------------------------------
    Libraries have been installed in:
    /usr/local/lib
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    during execution
    - add LIBDIR to the `LD_RUN_PATH' environment variable
    during linking
    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
    - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    /bin/mkdir -p '/usr/local/bin'
    /bin/bash ../libtool --mode=install /usr/bin/install -c protoc '/usr/local/bin'
    libtool: install: /usr/bin/install -c .libs/protoc /usr/local/bin/protoc
    /bin/mkdir -p '/usr/local/include'
    /bin/mkdir -p '/usr/local/include/google/protobuf'
    /usr/bin/install -c -m 644 google/protobuf/descriptor.proto '/usr/local/include/google/protobuf'
    /bin/mkdir -p '/usr/local/include/google/protobuf/compiler'
    /usr/bin/install -c -m 644 google/protobuf/compiler/plugin.proto '/usr/local/include/google/protobuf/compiler'
    /bin/mkdir -p '/usr/local/include'
    /bin/mkdir -p '/usr/local/include/google/protobuf/compiler/cpp'

    但是依旧没有改变版本,没有覆盖住。

    • 以下是我的protobuf现状:
    root@test:~# whereis protoc
    protoc: /usr/bin/protoc /usr/bin/X11/protoc /usr/local/bin/protoc /usr/share/man/man1/protoc.1.gz
    root@test:~# pip show protobuf
    Name: protobuf
    Version: 3.4.1
    Summary: Protocol Buffers
    Home-page: https://developers.google.com/protocol-buffers/
    Author: protobuf@googlegroups.com
    Author-email: protobuf@googlegroups.com
    License: 3-Clause BSD License
    Location: /root/anaconda2/lib/python2.7/site-packages
    Requires: six, setuptools
    You are using pip version 9.0.1, however version 9.0.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    root@test:~# which protoc
    /root/anaconda2/bin/protoc
    root@test:~# protoc --version
    libprotoc 3.4.0
    root@test:~# 

    博客一:http://blog.csdn.net/elysion122/article/details/64523339的说法只能改变使用sudo命令下的提取位置,而且我还不知道怎么编我自己的路径。

    http://blog.csdn.net/whoamiyang/article/details/52947225我的安装来源液体到了路径,不过我怀疑其实我都没有安装上,由于我的版本比较新,所以我打算用pip把它卸载了,关键是我怎么让caffe听我的话去找protobuf用

    我怀疑我的caffe用的是电脑的protobuf,在我用sudo make all的时候提示我语言不通,因为我这时用的是2.5的protobuf,用的是博客一的默认路径Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

    当我用make all的时候提示我升级版本。如果我能够知道我的caffe上哪里找的protobuf就好了。

    知乎上这个也许可用,前提是我找到了对的protobuf:

    https://www.zhihu.com/question/58592005/answer/188884890

     

    我用cmake出现了

    incompatible with your Protocol Buffer headers.  Please update

    这个错误

    --   Release CXX flags :   -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
    --   Debug CXX flags   :   -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
    --   Build type        :   Release
    -- 
    --   BUILD_SHARED_LIBS :   ON
    --   BUILD_python      :   ON
    --   BUILD_matlab      :   OFF
    --   BUILD_docs        :   ON
    --   CPU_ONLY          :   OFF
    -- 
    -- Dependencies:
    --   BLAS              :   Yes (Atlas)
    --   Boost             :   Yes (ver. 1.54)
    --   glog              :   Yes
    --   gflags            :   Yes
    --   protobuf          :   Yes (ver. 2.6.1)
    --   lmdb              :   Yes (ver. 0.9.16)
    --   Snappy            :   Yes (ver. 1.1.0)
    --   LevelDB           :   Yes (ver. 1.15)
    --   OpenCV            :   Yes (ver. 2.4.8)
    --   CUDA              :   Yes (ver. 8.0)

    以下是make all的错误:

    CXX tools/upgrade_net_proto_text.cpp
    CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::AssignDescriptors(std::string const&, google::protobuf::internal::MigrationSchema const*, google::protobuf::Message const* const*, unsigned int const*, google::protobuf::MessageFactory*, google::protobuf::Metadata*, google::protobuf::EnumDescriptor const**, google::protobuf::ServiceDescriptor const**)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::SerializeToString(std::string*) const'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::OnShutdownDestroyString(std::string const*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::fixed_address_empty_string'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)'
    .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const'
    collect2: error: ld returned 1 exit status
    make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
    root@test:/dev/LT/SegNet/caffe-segnet# 

     http://blog.csdn.net/xiexievv/article/details/47396725

    折腾了全部的路径也不管用。

    开始解决

    本教程适用于折腾半天还不管事,无奈之举。以及不能卸载(与别人共用服务器)

    中心思想,找到系统认准的protoc,用你想要的版本替换他。

    你需要

    1.你需要的protobuf版本

    2.该版本被你安装在哪

    3.你系统认准的protobuf版本在哪

    4.告诉你的系统,去哪里找lib

    1安装你需要的protobuf

    这个没什么好说的,不过提醒你最好用prefix装在你指定的目录,.configure --help看看怎么用prefix

     

    ./configure --prefix=/root/LT

     

     

    2.找到你刚安装的protobuf

    进入他的lib文件夹:

    比如我就不同寻常的装到了LT文件夹里:不走寻常路,记住这个protoc。

     3.找到你系统认定的protoc在哪

    终端输入:

    你也可以用命令行,找到这个protoc,给他改个名字,比如protoc_origin,然后把你想要的版本粘贴过来.这时候再输入

    protoc --version

     4.在/etc/ld.so.conf.d文件夹里面创建libprotobuf.conf

     我在LT这么一个奇葩文件夹里面安装的,前面已经说过,所以我的lib也在这。所以我要在里面输入/root/LT/lib

    这时候版本就变了。由于不能卸载,所以我尝试过各种办法,然而都不好使。

    如果你用caffe,请不要在makefile.config中用anaconda,要自己配置各种前置,不过没准你就好使了呢。

    为什么说无奈之举呢,因为这不是作者给的。而且是身首分离的,改变不了系统认准的地址,只能替换。我试过bashrc,命令行暂时的export也试过,都不能让系统上LT找protobuf。不走常规的方式可能有风险。

    本博客专注于错误锦集,在作死的边缘试探
  • 相关阅读:
    extend()和append()区别
    extend()和append()区别
    extend()和append()区别
    extend()和append()区别
    Ethtool工具源码剖析
    [数据库基础]——索引
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/SweetBeens/p/8619912.html
Copyright © 2011-2022 走看看