Skip to content

Instantly share code, notes, and snippets.

@vaibhaw
Last active December 11, 2015 18:10
Show Gist options
  • Save vaibhaw/dc02c33031288344900b to your computer and use it in GitHub Desktop.
Save vaibhaw/dc02c33031288344900b to your computer and use it in GitHub Desktop.
# based on https://gist.github.com/amirsani/d2aa0763cc138902bf73
# Read this two also
# http://stackoverflow.com/questions/11443302/compiling-numpy-with-openblas-integration/14391693#14391693
# http://osdf.github.io/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.htmlhttp://osdf.github.io/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.html
# OS dependencies
sudo apt-get install -y build-essential gfortran
sudo apt-get install -y git curl vim
# Python dependencies
sudo apt-get install -y python-dev python-pip
sudo pip install cython
sudo pip install nose
# Install OpenBLAS
git clone git://github.com/xianyi/OpenBLAS
pushd OpenBLAS
make FC=gfortran
sudo make PREFIX=/usr/local/ install
popd
## If there is no other BLAS library installed on your system,
## OpenBLAS would be used as BLAS library
## If there are any other libraries use the following configuration options
# Numpy
git clone https://github.com/numpy/numpy
pushd numpy
# vim site.cfg # and put the following content within #### in site.cfg
####
# [default]
# library_dirs = /usr/local/lib
# [atlas]
# atlas_libs = openblas
# library_dirs = /usr/local/lib
# [lapack]
# lapack_libs = openblas
# library_dirs = /usr/local/lib
export BLAS=/usr/local/lib/libopenblas.a
export LAPACK=/usr/local/lib/libopenblas.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
python setup.py build
# verify existence of build/lib.*/numpy/core/_dotblas.so
# newer numpy don't create this file. Instead multiarray.so links to libopenblas.so
# run test_numpy.py
sudo python setup.py install
popd
# Scipy
git clone https://github.com/scipy/scipy
pushd scipy
python setup.py build
sudo BLAS=/usr/local/lib/libopenblas.a LAPACK=/usr/local/lib/libopenblas.a LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ python setup.py install
# run test_scipy.py
popd
# Matplotlib
sudo apt-get install libfreetype6-dev libpng12-dev
git clone git://github.com/matplotlib/matplotlib.git
pushd matplotlib
python setup.py build
sudo python setup.py install
popd
# run unit tests
python -c "import numpy; numpy.test(verbose=2)"
python -c "import scipy; scipy.test(verbose=2)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment