如何在conda环境中用克隆的GitHub版本替换libprotobuf的conda软件包

问题描述 投票:0回答:1

我正在尝试在caffe环境中安装condaCaffe需要Google的protobuf软件包。我已经git cloneprotobuf,并将其保存在我的\usr目录中。但是,当我尝试在conda环境中安装caffe时,安装的libprotobuf版本无法将proto文件正确转换为c++代码。

请考虑以下代码:

syntax = "proto2";

package test1;


message Datum {
  optional int32 channels = 1;
}

[当我尝试从base环境中进行翻译时,一切都很好:

(base) me@balin:~/Projects/caffe$ make clean
(base) me@balin:~/Projects/caffe$ make superclean
Deleting the following generated files:
./temp5.pb.cc
./temp5.pb.h
(base) me@balin:~/Projects/caffe$ protoc --cpp_out=. temp5.proto
(base) me@balin:~/Projects/caffe$ g++ temp5.pb.cc -c
(base) me@balin:~/Projects/caffe$ 

但是,当我在要用于caffe的环境中尝试相同的操作时,会得到以下结果:

(dnn_track5) me@balin:~/Projects/caffe$ make clean
(dnn_track5) me@balin:~/Projects/caffe$ make superclean
Deleting the following generated files:
./temp5.pb.cc
(dnn_track5) me@balin:~/Projects/caffe$ protoc --cpp_out=. temp5.proto
(dnn_track5) me@balin:~/Projects/caffe$ g++ temp5.pb.cc -c
temp5.pb.cc: In member function ‘virtual const char* test1::Datum::_InternalParse(const char*, google::protobuf::internal::ParseContext*)’:
temp5.pb.cc:150:58: error: ‘ReadVarint’ is not a member of ‘google::protobuf::internal’
           channels_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
                                                          ^~~~~~~~~~
temp5.pb.cc:150:58: note: suggested alternative: ‘ReadVarint32’
           channels_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr);
                                                          ^~~~~~~~~~
                                                          ReadVarint32

[我所能做的就是用我从~\anaconda2\envs\dnn_track5克隆构建conda时安装的文件替换protobuf所安装的GitHub子目录中的每个文件。我是否正确(我对此表示怀疑)。

我如何创建一个conda环境,在其中我可以使用caffe并且仍然可以使用protobuf

python anaconda conda protobuf-c
1个回答
0
投票

没有直接使用conda从github存储库直接安装的方法,因此值得一看为什么您的代码无法在您的caffe环境中工作。

截至this commit(自2019年10月起)之间有区别>

::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64

::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32

[当您conda install caffe时,它下载(至少对我而言)libprotobuf-3.11.2,它是2019年12月的最新版本,因此,作为caffe的依赖项下载的版本实际上比您尝试的要新。在您的代码中使用。

您现在有几个选择:

  1. 请求具有您要使用的API的protobuf的特定版本。即3.10.0,从2019年10月3日开始:

    conda create -n caffe -c conda-forge python=3.7 caffe libprotobuf=3.10.0

  2. 创建自定义的conda频道并在其中放置自己的libprotobuf.tar.bz2

  3. 调整您的代码以使用最新的MoselibprotobufAPI
© www.soinside.com 2019 - 2024. All rights reserved.