Ubuntu 16.04下安裝Caffe解決 undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE
阿新 • • 發佈:2018-11-18
今天安裝Caffe框架,make時一切正常,但import caffe時出現以下錯誤
>>> import caffe Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/jcole/Git/caffe/python/caffe/__init__.py", line 1, in <module> from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer File "/home/jcole/Git/caffe/python/caffe/pycaffe.py", line 13, in <module> from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: /home/jcole/Git/caffe/python/caffe/_caffe.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE
Google該錯誤,發現原因是boost_python的版本不匹配,預設python版本為3.5,而boost_python為2.7。
解決方法:
先在系統的/usr/lib/x86_64-linux-gnu/路徑下查詢boost_python檔案的版本是否與python版本匹配,我的電腦中檔名為:
libboost_python-py35.so.1.58.0
說明版本為python3.5,匹配。若不匹配則安裝對應的boost_python版本。
接下來開啟Caffe資料夾下的Makefile檔案,將第208行的
PYTHON_LIBRARIES := boost_python python2.7
改為
PYTHON_LIBRARIES := boost_python-py35 #py35需要改為你自己的python版本,如py34,py33
接著重新編譯檔案:
make clean
sudo ldconfig
make caffe
make all
make test
再次import caffe,沒有報錯。