centos安装caffe python接口时候可能出现错误

在CentOS上安装Caffe的Python接口时,可能会遇到安装pip、scipy和scikit-image时找不到依赖包的问题,特别是numpy。错误通常由于numpy安装在/usr/lib64而非/usr/lib下。解决方案包括修改Makefile.config的Python包含路径,并在遇到Gdk-CRITICAL错误时,由于matplotlib绘图需求,需要在import caffe前添加特殊代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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') 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值