caffe:/usr/bin/ld: cannot find -lcblas

Viewed 6118

I have installed BLAS in my CentOS7(64 bit).But when my use make all in my

'caffe'.It reports an eror:

/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

I dont know why this happened and how to resolve it.

4 Answers

I ended up using OpenBLAS to work around this problem.

yum install openblas-devel
sed -i 's/BLAS := atlas/BLAS := open/' Makefile.config
sed -i '/BLAS := open/aBLAS_INCLUDE := \/usr\/include\/openblas/' Makefile.config

which means install OpenBLAS and change BLAS := altas to BLAS := open and add BLAS_INCLUDE := /usr/include/openblas/ in Makefile.config. Once you have made these changes, rebuild.

First issue

sudo yum install atlas-devel

and then add the following lines to your Makefile.config

BLAS_INCLUDE := /usr/include
BLAS_LIB := /usr/lib64/atlas

in the target shared library section. The section after adding the change looks like the following

 36 # The target shared library name
 37 LIBRARY_NAME := $(PROJECT)
 38 LIB_BUILD_DIR := $(BUILD_DIR)/lib
 39 STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
 40 DYNAMIC_VERSION_MAJOR       := 1
 41 DYNAMIC_VERSION_MINOR       := 0
 42 DYNAMIC_VERSION_REVISION    := 0-rc3
 43 DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
 44 #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
 45 DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_    MINOR).$(DYNAMIC_VERSION_REVISION)
 46 DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
 47 COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSI    ON_REVISION)
 48 
 49 BLAS_INCLUDE := /usr/include
 50 BLAS_LIB := /usr/lib64/atlas

I also faced the same problem when building caffe on the amazon deep learning ami and found the solution here: https://groups.google.com/forum/#!topic/caffe-users/Pyfp9eQoIMQ

Related