Commit 7b8fca2a authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files

Installation advice on numpy+openblas

parent c6d749fd4b14
Numpy installation with BLAS and LAPACK
=======================================
Numpy can potentially perform better when it can make use of
`BLAS <https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms>`_
/ `LAPACK <https://en.wikipedia.org/wiki/LAPACK>`_ libraries.
Popular implementations include OpenBLAS, ATLAS and Intel MKL.
Run `fluidinfo -v` to see if your existing `numpy` installation detects any of
the above libraries already provided in the system. If these libraries are
available and `numpy` cannot detect such libraries you may need to configure
the paths into a file located at `$HOME/.numpy-site.cfg` (`See example
<https://raw.githubusercontent.com/numpy/numpy/master/site.cfg.example>`_)
OpenBLAS library
----------------
If none of the above libraries are not available, it may be worthwhile to
install it yourself using the following shell script:
.. literalinclude:: install_openblas.sh
:language: shell
......@@ -28,6 +28,7 @@ install the FFTW library.
.. literalinclude:: install_fftw.sh
:language: shell
MKL library (FFT by intel)
--------------------------
......
......@@ -15,8 +15,17 @@ Dependencies
.. note::
Be careful, the wheels install with `pip install numpy` can be slow. You
might get something more efficient by compiling from source using `pip
install numpy --no-binary numpy`.
might get something more efficient by compiling from source using:
.. code:: bash
pip install numpy --no-binary numpy
python -c 'import numpy; numpy.test()'
.. toctree::
:maxdepth: 1
blas_libs
.. warning::
......
......@@ -16,10 +16,10 @@ export MAKEFLAGS="-j$(nproc)"
download() {
cd ${srcdir}
if [ ! -f $pkgname-$pkgver.tar.gz ]; then
wget http://www.fftw.org/$pkgname-$pkgver.tar.gz
if [ ! -f ${pkgname}-${pkgver}.tar.gz ]; then
wget http://www.fftw.org/${pkgname}-${pkgver}.tar.gz
fi
tar vxzf $pkgname-$pkgver.tar.gz
tar vxzf ${pkgname}-${pkgver}.tar.gz
}
build() {
......
#!/bin/bash
# Customizable variables
# ----------------------
pkgname='OpenBLAS'
pkgver=0.2.20
_lapackver=3.7.0
# Directory in which the source tarball will be downloaded and extracted
srcdir=$PWD
# Directory to which the compiled OpenBLAS library will be installed
pkgdir="$HOME/.local/${pkgname}-${pkgver}"
fcompiler="gfortran"
# Should be no reason to change anything below
# --------------------------------------------
_config="FC=${fcompiler} USE_OPENMP=0 USE_THREAD=1 \
NO_LAPACK=0 BUILD_LAPACK_DEPRECATED=1\
MAKE_NB_JOBS=$(nproc)
"
download() {
cd ${srcdir}
if [ ! -f ${pkgname}-${pkgver}.tar.gz ]; then
wget http://github.com/xianyi/OpenBLAS/archive/v${pkgver}.tar.gz
fi
tar vxzf ${pkgname}-${pkgver}.tar.gz
}
build(){
cd ${srcdir}/${pkgname}-${pkgver}
make ${_config} libs netlib shared
}
check(){
cd ${srcdir}/${pkgname}-${pkgver}
make ${_config} tests
}
package(){
cd ${srcdir}/${pkgname}-${pkgver}
make ${_config} PREFIX=${pkgdir} install
cd ${pkgdir}
# BLAS
ln -sf libopenblas.so libblas.so
ln -sf libopenblas.so libblas.so.${_lapackver:0:1}
ln -sf libopenblas.so libblas.so.${_lapackver}
# CBLAS
ln -sf libopenblas.so libcblas.so
ln -sf libopenblas.so libcblas.so.${_lapackver:0:1}
ln -sf libopenblas.so libcblas.so.${_lapackver}
# LAPACK
ln -sf libopenblas.so liblapack.so
ln -sf libopenblas.so liblapack.so.${_lapackver:0:1}
ln -sf libopenblas.so liblapack.so.${_lapackver}
# LAPACKE
ln -sf libopenblas.so liblapacke.so
ln -sf libopenblas.so liblapacke.so.${_lapackver:0:1}
ln -sf libopenblas.so liblapacke.so.${_lapackver}
echo "
Installation complete!
Create $HOME/.numpy-site.cfg with
[openblas]
libraries = openblas
library_dirs = ${pkgdir}/lib
include_dirs = ${pkgdir}/include
runtime_library_dirs = ${pkgdir}/lib
to use this OpenBLAS installation.
"
}
# Execute the functions above
# ---------------------------
if [ ! -d ${srcdir}/${pkgname}-${pkgver} ]
then
download
fi
build
check
package
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment