caffe中使用python自定义层出现protobuf版本不对

1. 编译问题 

  1. 先执行  sudo easy_install setproctitlepython

  2. 打开Makefile.config, 反注释:WITH_PYTHON_LAYER := 1
  3. 执行以下命令,便可从新编译环境。(支持python自定义层的caffe环境。)
sudo make clean
sudo make -j4
sudo make pycaffe
sudo make distribute

 

2. 可能出现的问题

ImportError: No module named voc_layers

可能缘由及解决方案:git

  a. 编译问题, 使用上面的命令从新编译caffe环境。github

  b. 指定的层在PYTHONPATH中找不到ui

    解决方案分两种,i. 将voc_layers.py 文件复制到PYTHONPATH其中目录之一下,google

      ii. 将voc_layers.py 所在的目录添加到PYTHONPATH中。spa

 

 

This program requires version 3.5.0 of the Protocol Buffer runtime library

具体详细日志以下:日志


 

[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.2.0 of the Protocol Buffer runtime library, but the installed version is 2.5.0. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)code


日志说明:即protobuf的版本不对,这里的protobuf版本只python中的版本和caffe里面的protobuf版本对不上。和系统中的protobuf 版本无关。 blog

官方issue:https://github.com/BVLC/caffe/issues/5711ip

解决方案: 千万不能升级!!!千万不能升级!!!千万不能升级!!!

   执行以下命令:

sudo pip uninstall protobuf

sudo pip install protobuf==2.5.0 

 

sudo pip2 uninstall protobuf

sudo pip2 install protobuf==2.5.0

python2和python3都须要卸载 上面的4行命令即:卸载python2和python3下的protobuf,同时从新安装2.5.0版本的protobuf。

能够到 /usr/local/lib/{pythonVersion}/dist-packages去查看的protobuf的版本,若是不是目标版本,再执行上面的4条命令,不一样版本下都须要删掉。

相关文章
相关标签/搜索