mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

blas issue compile issue

Open Yunrui opened this issue 11 years ago • 13 comments

hi all,

I am encountering the blas compile issue on EI Capitan. I searched and found similar questions about it, saying reason might be bias not installed. So I installed openblas thru brew, changed config file as "USE_BLAS = openblas". No luck. And I also tried to export LIBRARY_PATH=/usr/local/Cellar/openblas/0.2.15/include/, still got the exactly same error as below.

Anyone shed some light?

In file included from include/mxnet/base.h:13: In file included from ./mshadow/mshadow/tensor.h:16: ./mshadow/mshadow/./base.h:120:14: fatal error: 'cblas.h' file not found #include <cblas.h> ^ In file included from src/c_api/c_predict_api.cc:9: In file included from include/mxnet/symbolic.h:17: In file included from include/mxnet/./base.h:13: In file included from ./mshadow/mshadow/tensor.h:16: ./mshadow/mshadow/./base.h:120:14: fatal error: 'cblas.h' file not found #include <cblas.h> ^ In file included from src/c_api/c_api.cc:11: In file included from include/mxnet/base.h:13: In file included from ./mshadow/mshadow/tensor.h:16: ./mshadow/mshadow/./base.h:120:14: fatal error: 'cblas.h' file not found #include <cblas.h> ^ In file included from src/common/tblob_op_registry.cc:6: In file included from include/mxnet/ndarray.h:17: In file included from include/mxnet/./base.h:13: In file included from ./mshadow/mshadow/tensor.h:16: ./mshadow/mshadow/./base.h:120:14: fatal error: 'cblas.h' file not found #include <cblas.h> ^ 1 error generated. 1 error generated. 1 error generated. 1 errormake: *** [build/common/tblob_op_registry.o] Error 1 generated.

make: *** Waiting for unfinished jobs.... make: *** [build/c_api/c_predict_api.o] Error 1 make: *** [build/resource.o] Error 1 make: *** [build/c_api/c_api.o] Error 1

Yunrui avatar Nov 13 '15 17:11 Yunrui

An easier option is just to use the built-in BLAS of OS X:

USE_BLAS = apple

as in make/osx.mk

pluskid avatar Nov 13 '15 17:11 pluskid

actually, I used "USE_BLAS = apple" at the very beginning, but encounter the same build failure. Then I thought my bias was not installed correctly, then I tried open blas....

Yunrui avatar Nov 13 '15 17:11 Yunrui

You want to add the path to CPLUS_INCLUDE_PATH and C_INCLUDE_PATH. Or add them in -I flag in the ADD_CFLAGS

tqchen avatar Nov 13 '15 18:11 tqchen

modify the config.mk like this

USE_BLAS = apple
ADD_LDFLAGS = -I/usr/local/opt/openblas/lib
ADD_CFLAGS =  -I/usr/local/opt/openblas/include

antinucleon avatar Nov 13 '15 20:11 antinucleon

I had the exact similar issue before and my solution was: adding /usr/local/include and /usr/local/lib to the PATH, and USE_BLAS = apple

phunterlau avatar Nov 13 '15 21:11 phunterlau

thanks, the issue was resolved by adding ADD_LDFLAGS and ADD_CFLAGS

Yunrui avatar Nov 14 '15 01:11 Yunrui

As a reference, if those 3 lines are added to make/osx.mk, then the bash command in the docs remain the same: cd mxnet; cp make/osx.mk ./config.mk; make -j$(sysctl -n hw.ncpu)

martinbel avatar Aug 01 '16 18:08 martinbel

For ADD_LDFLAGS, it should be -L

LiberiFatali avatar Aug 30 '16 08:08 LiberiFatali

I also meet this error: In file included from /data/apps/mxnet/mshadow/mshadow/tensor.h:16:0, from include/mxnet/./base.h:13, from include/mxnet/operator_util.h:24, from src/operator/tensor/./elemwise_unary_op.h:9, from src/operator/tensor/elemwise_binary_scalar_op_extended.cc:6: /data/apps/mxnet/mshadow/mshadow/./base.h:136:23: fatal error: cblas.h: No such file or directory #include <cblas.h>

my environment: centos 7 gcc 4.8.5 glibc 2.17 opencv 2.4.13 openblas 0.2.19

I also vim .bashrc export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64:/opt/openblas/lib:/data/apps/opencv-2.4.13/release/lib sudo ldconfig

I try to fix the config.mk and fianlly build succussfully.

set config.mk

ADD_LDFLAGS = -I/opt/OpenBLAS/lib ADD_CFLAGS = -I/opt/OpenBLAS/include USE_BLAS = openblas

If you don't have libopenblas.so in your /usr/lib , then you can do the following thing, otherwise you maybe encouter the error: usr bin ld cannot find lopenblas ln -s /xxx/OpenBLAS/lib/libopenblas.so /usr/lib/libopenblas.so

defaultRobot avatar Dec 30 '16 11:12 defaultRobot

First install openblas

$ brew install --fresh -vd openblas
......
macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openblas/lib
    CPPFLAGS: -I/usr/local/opt/openblas/include

==> Summary
🍺  /usr/local/Cellar/openblas/0.2.18_2: 20 files, 41.8M, built in 12 minutes 33 seconds

Then Add ADD_LDFLAGS and ADD_CFLAGS to config.mk:

USE_BLAS = apple
ADD_LDFLAGS = -I/usr/local/opt/openblas/lib
ADD_CFLAGS =  -I/usr/local/opt/openblas/include

nodejh avatar Dec 31 '16 07:12 nodejh

apt-get install libblas-dev liblapack-dev

ChangliangSun avatar Jan 29 '18 07:01 ChangliangSun

OS used : MacOS I am sorry ,

But where is this config.mk or osx.mk file?

ShankarNara avatar Mar 22 '20 06:03 ShankarNara

OS used : MacOS I am sorry ,

But where is this config.mk or osx.mk file?

cp make/osx.mk ./config.mk then, find “USE_BLAS = apple” line add

lonelygo avatar Jul 06 '20 03:07 lonelygo