【发布时间】:2020-01-27 22:49:46
【问题描述】:
我正在尝试在conda 环境中安装caffe。 Caffe 需要 Google 的 protobuf 包。我已经有 git clone'd protobuf 并将它放在我的 \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
我能想到的就是将conda 安装的~\anaconda2\envs\dnn_track5 子目录中的每个文件替换为我从GitHub 克隆构建protobuf 时安装的文件。我在这方面是否正确(我对此表示怀疑)。
如何创建一个 conda 环境,我可以在其中使用 caffe 并且仍然可以使用 protobuf?
【问题讨论】:
-
你从 github 克隆的版本有多大,
conda安装了哪个版本。我不建议弄乱 conda 手动安装的文件
标签: python anaconda conda protobuf-c