python - Link ATLAS/MKL to an installed Numpy -
tl;dr how link atlas/mkl existing numpy without rebuilding.
i have used numpy calculate large matrix , found slow because numpy use 1 core calculation. after doing lot of search figure numpy not link optimized library atlas/mkl. here config of numpy:
>>>import numpy np >>>np.__config__.show() blas_info: libraries = ['blas'] library_dirs = ['/usr/lib'] language = f77 lapack_info: libraries = ['lapack'] library_dirs = ['/usr/lib'] language = f77 atlas_threads_info: not available blas_opt_info: libraries = ['blas'] library_dirs = ['/usr/lib'] language = f77 define_macros = [('no_atlas_info', 1)] atlas_blas_threads_info: not available openblas_info: not available lapack_opt_info: libraries = ['lapack', 'blas'] library_dirs = ['/usr/lib'] language = f77 define_macros = [('no_atlas_info', 1)] atlas_info: not available lapack_mkl_info: not available blas_mkl_info: not available atlas_blas_info: not available mkl_info: not available for reason, want link atlas/mkl numpy. however, numpy installed pip don't want install manually because want use latest version. have done search building scratch. reason, question are:
- are there way link atlas/mkl numpy without rebuilding again?
- i have found config info saved in _config_.py in installed folder of numpy. modifying solve problem? if yes, please show me how?
assuming you're running flavour of linux, here's 1 way it:
find out blas library numpy linked against using
ldd.for versions of numpy older v1.10:
$ ldd /<path_to_site-packages>/numpy/core/_dotblas.sofor example, if install numpy via
apt-get, links to... libblas.so.3 => /usr/lib/libblas.so.3 (0x00007fed81de8000) ...if
_dotblas.sodoesn't exist, means numpy failed detect blas libraries when installed, in case doesn't build of blas-dependent components. happens if install numpy usingpipwithout manually specifying blas library (see below). i'm afraid you'll have no option rebuild numpy if want link against external blas library.
for numpy v1.10 , newer:
_dotblas.sohas been removed recent versions of numpy, should able check dependencies ofmultiarray.soinstead:$ ldd /<path_to_site-packages>/numpy/core/multiarray.so
install atlas/mkl/openblas if haven't already. way, recommend openblas on atlas - take @ this answer (although benchmarking data bit out of date).
use
update-alternativescreate symlink new blas library of choice. example, if installedlibopenblas.so/opt/openblas/lib, do:$ sudo update-alternatives --install /usr/lib/libblas.so.3 \ libblas.so.3 \ /opt/openblas/lib/libopenblas.so \ 50you can have multiple symlinks configured single target library, allowing manually switch between multiple installed blas libraries.
for example, when call
$ sudo update-alternatives --config libblas.so.3, can choose between 1 of 3 libraries:selection path priority status ------------------------------------------------------------ 0 /opt/openblas/lib/libopenblas.so 40 auto mode 1 /opt/openblas/lib/libopenblas.so 40 manual mode 2 /usr/lib/atlas-base/atlas/libblas.so.3 35 manual mode * 3 /usr/lib/libblas/libblas.so.3 10 manual mode
if want "newest" version of numpy, take @ my answer on compiling numpy source openblas integration.
installing numpy blas support using pip
as @tndoan mentioned in comments, it's possible make pip respect particular configuration numpy placing config file in ~/.numpy-site.cfg - see this answer more details.
my personal preference configure , build numpy hand. it's not particularly difficult, , gives better control on numpy's configuration.
Comments
Post a Comment