gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 19:49:13 33 4
gpt4 key购买 nike

我正在尝试在 conda 环境中安装 caffeCaffe 需要 Google 的 protobuf 包。我已经有了 git clone 的 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

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

如何创建一个 conda 环境,在该环境中我可以使用 caffe 并仍然拥有可用的 protobuf

最佳答案

没有直接的方法可以使用 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。 IE。 3.10.0,自 2019 年 10 月 3 日起:

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

  2. 创建自定义 conda channel 并将您自己的 libprotobuf.tar.bz2 放入其中

  3. 调整您的代码以使用最新的 libprotobuf API

关于python - 如何在 conda 环境中用克隆的 GitHub 版本替换 libprotobuf 的 conda 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59940017/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com