centos安裝caffe python接口時候可能出現錯誤
1.安裝pip
sudo yum install python-pip
sudo pip install requests[security]
2.安裝scipy
# 出現找不到 lapack或blas
yum install lapack lapack-devel blas blas-devel
3.安裝scikit-image
# 出現找不到freetype和png、jpeg
sudo yum -y install freetype-devel
sudo yum install libpng-devel
sudo yum install libjpeg-devel
4.安裝過程中找不到其他依賴包(主要還是原來的pypip軟件源下載的問題)
比如在這個:
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('google-apputils')
可以通過下面命令手動安裝
pip install google-apputils
5.執行make pycaffe
的時候提示找不到numpy
python/caffe/_caffe.hpp:8:31: fatal error: numpy/arrayobject.h: No such file or directory
google了下:
Replicated for Fedora 20. Had the same problem, it appears to be that numpy was in the path /usr/lib64/python2.7/site-packages/numpy so you should change your Makefile.config’s Python include path to this. It happens when you install numpy through pip on a x64_86 computer. At least that’s the deal for Fedora.
這一般是因爲numpy沒有被caffe成功找到,通過觀察發現通過pip安裝numpy,是安裝到usr/lib64下面,不是lib下面。
修改Make.config裏面python路徑
/usr/lib64/python2.7/site-packages/numpy
6.import caffe出錯
(.:4962): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion ‘GDK_IS_DISPLAY (display)’ failed
這個錯誤一般是因爲你在遠程登陸服務器,而caffe python中 matplotlib是繪圖功能,需要在圖形界面才行,這時候可以在import之前加入如下代碼解決:
import matplotlib
matplotlib.use('Agg')