1. 程式人生 > >python 進行caffe 資料視覺化的 “No to_python (by-value)” 問題解決

python 進行caffe 資料視覺化的 “No to_python (by-value)” 問題解決

使用python 進行caffe 資料視覺化的時候可能會遇到下面的錯誤:

No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Blob<float> > 
No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Net<float> > 
No to_python (by-value) converter found for C++ type: boost::shared_ptr<caffe::Layer<float> > 


上面的錯誤是由於boost-1.60.0 引起的,如果是boost-1.59.0,就沒有上面問題,但是很容易無意中升級安裝包的時候把boost也升級了,就會造成上面的問題。

// Fix for caffe pythonwrapper for boost 1.6
boost::python::register_ptr_to_python<boost::shared_ptr<Blob<Dtype> > >();

boost::python::register_ptr_to_python<boost::shared_ptr<Net<Dtype> > >();

boost::python::register_ptr_to_python<boost::shared_ptr<Layer<Dtype> > >();

// End fix

然後回到caffe 目錄, 重新編譯pycaffe:

caffe$ make pycaffe -j16 

其中-j16 是使用多核cpu 進行編譯,可以快速完成,問題解決。