ibayer / fastFM

fastFM: A Library for Factorization Machines
http://ibayer.github.io/fastFM
Other
1.08k stars 206 forks source link

OpenBLAS support #41

Closed arogozhnikov closed 8 years ago

arogozhnikov commented 8 years ago

It would be nice to support OpenBLAS, since this one is faster, and also demanded i.e. by theano.

At this moment pip install fastFM fails for OpenBLAS on ubuntu:

gcc -pthread -shared -L/moosefs/miniconda/envs/ipython_py2/lib -Wl,-rpath=/moosefs/miniconda/envs/ipython_py2/lib,--no-as-needed build/temp.linux-x86_64-2.7/fastFM/ffm.o -LfastFM/ -LfastFM-core/bin/ -LfastFM-core/externals/CXSparse/Lib/ -L/usr/lib/ -L/usr/lib/atlas-base/ -L/moosefs/miniconda/envs/ipython_py2/lib -lm -lfastfm -lcxsparse -lcblas -lpython2.7 -o build/lib.linux-x86_64-2.7/ffm.so
  /usr/bin/ld: cannot find -lcblas
  collect2: error: ld returned 1 exit status

I am not sure about consequences of changing BLAS (last time it required reinstalling whole scipy-stack), so I'd prefer not touch it :)

ibayer commented 8 years ago

I don't think using OpenBLAS will lead to a noticeable speed-up, nearly all runtime critical operations involve sparse matrices, which are not done by BLAS anyhow.

linking again different BLAS implementation Supporting OpenBLAS doesn't require any changes of fastFM's source code, it's all about linking against a different BLAS implementation (the header is always the same). I think this requires changes at two places:

  1. https://github.com/ibayer/fastFM/blob/master/setup.py#L10
  2. https://github.com/ibayer/fastFM-core/blob/2ab4edbd403c4a5a7781cf861e1d8c3b2a87b3c5/src/Makefile#L3

It would be great if we could use the BLAS implementation used by SciPy, since SciPy is a dependency anyway. This would remove the need to manually install BLAS. I'm not sure how to do this, but this paper Circumventing The Linker: Using SciPy’s BLAS and LAPACK Within Cython could be helpful.