您的位置:首页 > 运维架构 > Linux

CentOs7下,Caffe环境安装问题解决

2017-04-06 18:26 316 查看
准备在CentOS 7 下重新安装Caffe,centos7很不错,基本上官方文档里的:

sudo yum install protobuf-devel leveldb-devel snappy-devel opencv-devel boost-devel hdf5-devel

sudo yum install gflags-devel glog-devel lmdb-devel

可以顺利执行完成,接着根据文档:

BLAS:
install ATLAS by 
sudo yum install atlas-devel
 or
install OpenBLAS or MKL for better CPU performance. For the Makefile build, uncomment and set 
BLAS_LIB
 accordingly
as ATLAS is usually installed under 
/usr/lib[64]/atlas
).

安装atlas-devel。

开始编译~

make all 

报错:

[root@**** caffe]# make all 

CXX/LD -o .build_release/tools/convert_imageset.bin

/bin/ld: cannot find -lcblas

/bin/ld: cannot find -latlas

collect2: error: ld returned 1 exit status
查了一下,是程序在我们配置的lib目录里找不到atlas的so文件,比对了一下ld命令的查找方式和我们已安装的atlas:

ld -latlas --verbose

显示查找路径如下:

==================================================

attempt to open /usr/x86_64-redhat-linux/lib64/libatlas.so failed

attempt to open /usr/x86_64-redhat-linux/lib64/libatlas.a failed

attempt to open /usr/lib64/libatlas.so failed

attempt to open /usr/lib64/libatlas.a failed

attempt to open /usr/local/lib64/libatlas.so failed

attempt to open /usr/local/lib64/libatlas.a failed

attempt to open /lib64/libatlas.so failed

attempt to open /lib64/libatlas.a failed

attempt to open /usr/x86_64-redhat-linux/lib/libatlas.so failed

attempt to open /usr/x86_64-redhat-linux/lib/libatlas.a failed

attempt to open /usr/local/lib/libatlas.so failed

attempt to open /usr/local/lib/libatlas.a failed

attempt to open /lib/libatlas.so failed

attempt to open /lib/libatlas.a failed

attempt to open /usr/lib/libatlas.so failed

attempt to open /usr/lib/libatlas.a failed

ld: cannot find -latlas

我看了一下我们安装的atlas,在/usr/lib64/atlas/下,内有这些so:

[root@*** caffe]# ll /usr/lib64/atlas

total 21304

lrwxrwxrwx 1 root root       17 Apr  6 04:38 libsatlas.so -> libsatlas.so.3.10

lrwxrwxrwx 1 root root       17 Mar 14 22:24 libsatlas.so.3 -> libsatlas.so.3.10

-rwxr-xr-x 1 root root 10852104 Nov 20  2015 libsatlas.so.3.10

lrwxrwxrwx 1 root root       17 Apr  6 04:38 libtatlas.so -> libtatlas.so.3.10

lrwxrwxrwx 1 root root       17 Mar 14 22:24 libtatlas.so.3 -> libtatlas.so.3.10

-rwxr-xr-x 1 root root 10959464 Nov 20  2015 libtatlas.so.3.10

我们安装的atlas的so库只有libsatlas和libtatlas两种,与caffe要的完全不匹配。

查了一些材料(https://www.centos.org/forums/viewtopic.php?t=48543),这个提问里有提到这个现象,在centOS7下,库名已改,引入方式也要改变:

Names and content of atlas libraries have changed recently. Try

-L/usr/lib64/atlas -lsatlas or -L/usr/lib64/atlas -ltatlas

instead of

-lcblas.   

但我并不想去修改caffe源码,担心引起连锁问题,且报错中并没有提示具体发生问题的文件。

解决方案

改用openblas:

yum install  openblas-devel

MakeFile.config配置如下:

BLAS := open

# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.

# Leave commented to accept the defaults for your choice of BLAS

# (which should work)!

#BLAS_INCLUDE := /usr/include/atlas

#BLAS_LIB := /usr/lib64/atlas

后续一切成功。 done。

建议Caffe对CentOS 7 下atlas引用失败的问题做修复。有空提个issue。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  caffe
相关文章推荐