I “import caffe” from ipython, but I got “RuntimeWarning”. How to resolve it?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 04:02:04

问题


I have read the article "Ubuntu Installation --Guide for Ubuntu 14.04 with a 64 bit processor." from Github website (https://github.com/tiangolo/caffe/blob/ubuntu-tutorial-b/docs/install_apt2.md). And now, I open IPython to test that PyCaffe is working. I input "ipython" command, and enter to the ipython page.

Then, I input the command "import caffe", but I got below warnings:

/root/code/caffe-master/python/caffe/pycaffe.py:13:RuntimeWarning: to-Python converter for boost::shared_ptr > already registered; second conversion method ignored. from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \

/root/code/caffe-master/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr > already registered; second conversion method ignored. from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \

/root/code/caffe-master/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr > already registered; second conversion method ignored. from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \

Would you please help to give me some suggestions to resolve it?


回答1:


I found this:

https://groups.google.com/forum/#!topic/caffe-users/C_air48cISU

Claiming that this is a non-error, cause by mis-matched versions of Boost. You can safely ignore it. They've promised to clean up the warning (at some point not yet specified)




回答2:


You can edit /caffe/python/caffe/_caffe.cpp . There are four places need to change,like this

bp::register_ptr_to_python<shared_ptr<Layer<Dtype> > >();

to

const boost::python::type_info cinfo = boost::python::type_id<shared_ptr<Blob<Dtype> > >();
const boost::python::converter::registration* creg = boost::python::converter::registry::query(cinfo);
      if (creg == NULL)
      {
         bp::register_ptr_to_python<shared_ptr<Layer<Dtype> > >();
      }
      else if ((*creg).m_to_python == NULL) {
         bp::register_ptr_to_python<shared_ptr<Layer<Dtype> > >();
      }

then compile use 'make pycaffe' ,it will be ok.



来源:https://stackoverflow.com/questions/35823709/i-import-caffe-from-ipython-but-i-got-runtimewarning-how-to-resolve-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!