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
[]


你可能感兴趣的:(#,Caffe2PyTorch,线上问题,Caffe2,pytorch)