Caffe2问题总结(一)

1 没有google模块

【Problem】

from google.protobuf.internal import enum_type_wrapper
ModuleNotFoundError: No module named 'google'

【Reason】
缺少protobuf。
【Solve】

pip install protobuf

2 调用lmdb文件失败

【Problem】
RuntimeError: [enforce fail at db.h:196] db_. Cannot find db implementation of type lmdb (while trying to open /home/xdq/xinPrj/python/jupyter/Caffe2Pytorch/turorial_data/mnist/mnist-train-nchw-lmdb)
Error from operator:
output: “dbreader_/home/xdq/xinPrj/python/jupyter/Caffe2Pytorch/turorial_data/mnist/mnist-train-nchw-lmdb” name: “” type: “CreateDB” arg { name: “db” s: “/home/xdq/xinPrj/python/jupyter/Caffe2Pytorch/turorial_data/mnist/mnist-train-nchw-lmdb” } arg { name: “db_type” s: “lmdb” }frame #0: c10::ThrowEnforceNotMet(char const*, int, char const*, std::string const&, void const*) + 0x59 (0x7f01f1d09409 in /home/xdq/anaconda3/envs/caffe2_py3/lib/python3.6/site-packages/caffe2/python/…/…/torch/lib/libc10.so)
【Reason】
没有开启读取lmdb文件配置。
【Solve】
conda环境编译安装Caffe2
【(1) requirements.txt】

sudo apt-get update
sudo apt-get install -y --no-install-recommends \
      build-essential \
      git \
      libgoogle-glog-dev \
      libgtest-dev \
      libiomp-dev \
      libleveldb-dev \
      liblmdb-dev \
      libopencv-dev \
      libopenmpi-dev \
      libsnappy-dev \
      libprotobuf-dev \
      openmpi-bin \
      openmpi-doc \
      protobuf-compiler \
      python-dev \
      python-pip                          
pip install --user \
      future \
      numpy \
      protobuf \
      typing \
      hypothesis
# for Ubuntu 14.04
sudo apt-get install -y --no-install-recommends \
      libgflags2 \
      cmake3
# for Ubuntu 16.04
sudo apt-get install -y --no-install-recommends \
      libgflags-dev \
      cmake

【(2) conda环境激活】

conda activate 4pytorch

【(2) 编译安装】
这些操作在conda的环境中操作。

# 进入文件夹如
cd xinPrj
# 下载项目源码
git clone https://github.com/pytorch/pytorch.git && cd pytorch
# 更新子模块
git submodule update --init --recursive
# 开启使用LMDB数据并编译安装caffe2
# USE_LMDB=ON是关键
USE_LMDB=ON python setup.py install

【(3) 安装完毕】

running install_scripts
# conda虚拟环境为:/home/xdq/anaconda3/envs/4pytorch/
Installing convert-caffe2-to-onnx script to /home/xdq/anaconda3/envs/4pytorch/bin
Installing convert-onnx-to-caffe2 script to /home/xdq/anaconda3/envs/4pytorch/bin

【参考文献】
[1]https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=compile
[2]https://github.com/pytorch/pytorch/issues/10119
[]


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
安装Caffe在Ubuntu上主要有两种方式,一种是通过源码编译安装,另一种是通过apt命令安装。根据引用和引用的信息,如果你的Ubuntu版本是16.04并且没有GPU,你可以按照以下步骤安装Caffe: 1.首先,确保你的电脑没有GPU。你可以通过引用中提到的方法检查。 2.打开终端,执行以下命令安装Caffe的依赖项: sudo apt update sudo apt install build-essential cmake git libatlas-base-dev libboost-all-dev libgflags-dev libgoogle-glog-dev libhdf5-serial-dev liblmdb-dev libprotobuf-dev libsnappy-dev protobuf-compiler 3.使用git克隆Caffe的源码: git clone https://github.com/BVLC/caffe.git cd caffe git checkout 1.0 4.配置Caffe并编译: cp Makefile.config.example Makefile.config 修改Makefile.config中的配置,根据需要启用或禁用相关选项。 make all make test make runtest 现在,你已经成功安装了Caffe。你可以根据你的需求进一步使用它。 如果你的Ubuntu版本是17.04以上,你可以按照引用中提到的方式通过apt命令安装Caffe: sudo apt install caffe-cpu 另外,根据引用,你还可以考虑升级你的Ubuntu版本到18.04 LTS,以获得更好的系统性能和稳定性。 总结起来,根据你的Ubuntu版本和是否有GPU,你可以选择源码编译安装或通过apt命令安装Caffe。希望这些信息对你有帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Ubuntu18.04安装caffe(cpu)—-简单易操作:只需三步!](https://blog.csdn.net/yllifesong/article/details/80980367)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天然玩家

坚持才能做到极致

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值