Skip to content

Commit

Permalink
MAINT Remove BLAS infos from show_versions and build log (scikit-lear…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiedbb authored and rth committed Jul 18, 2019
1 parent 67130a5 commit 01a140a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 107 deletions.
7 changes: 0 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ Matplotlib (>= 1.5.1). For running the examples Matplotlib >= 1.5.1 is
required. A few examples require scikit-image >= 0.12.3, a few examples require
pandas >= 0.18.0.

scikit-learn also uses CBLAS, the C interface to the Basic Linear Algebra
Subprograms library. scikit-learn comes with a reference implementation, but
the system CBLAS will be detected by the build system and used if present.
CBLAS exists in many implementations; see `Linear algebra libraries
<http://scikit-learn.org/stable/modules/computing#linear-algebra-libraries>`_
for known issues.

User installation
~~~~~~~~~~~~~~~~~

Expand Down
52 changes: 17 additions & 35 deletions doc/developers/advanced_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,56 +193,38 @@ Installing build dependencies
Linux
-----

Installing from source requires you to have installed the scikit-learn runtime
dependencies, Python development headers and a working C/C++ compiler.
Under Debian-based operating systems, which include Ubuntu::
Installing from source without conda requires you to have installed the
scikit-learn runtime dependencies, Python development headers and a working
C/C++ compiler. Under Debian-based operating systems, which include Ubuntu::

sudo apt-get install build-essential python3-dev python3-setuptools \
python3-numpy python3-scipy \
libatlas-dev libatlas3-base

On recent Debian and Ubuntu (e.g. Ubuntu 14.04 or later) make sure that ATLAS
is used to provide the implementation of the BLAS and LAPACK linear algebra
routines::
python3-pip
and then::

sudo update-alternatives --set libblas.so.3 \
/usr/lib/atlas-base/atlas/libblas.so.3
sudo update-alternatives --set liblapack.so.3 \
/usr/lib/atlas-base/atlas/liblapack.so.3
pip3 install numpy scipy cython

.. note::

In order to build the documentation and run the example code contains in
this documentation you will need matplotlib::

sudo apt-get install python-matplotlib

.. note::

The above installs the ATLAS implementation of BLAS
(the Basic Linear Algebra Subprograms library).
Ubuntu 11.10 and later, and recent (testing) versions of Debian,
offer an alternative implementation called OpenBLAS.
pip3 install matplotlib

Using OpenBLAS can give speedups in some scikit-learn modules,
but can freeze joblib/multiprocessing prior to OpenBLAS version 0.2.8-4,
so using it is not recommended unless you know what you're doing.
When precompiled wheels are not avalaible for your architecture, you can
install the system versions::

If you do want to use OpenBLAS, then replacing ATLAS only requires a couple
of commands. ATLAS has to be removed, otherwise NumPy may not work::

sudo apt-get remove libatlas3gf-base libatlas-dev
sudo apt-get install libopenblas-dev

sudo update-alternatives --set libblas.so.3 \
/usr/lib/openblas-base/libopenblas.so.0
sudo update-alternatives --set liblapack.so.3 \
/usr/lib/lapack/liblapack.so.3
sudo apt-get install cython3 python3-numpy python3-scipy python3-matplotlib

On Red Hat and clones (e.g. CentOS), install the dependencies using::

sudo yum -y install gcc gcc-c++ numpy python-devel scipy
sudo yum -y install gcc gcc-c++ python-devel numpy scipy

.. note::

To use a high performance BLAS library (e.g. OpenBlas) see
`scipy installation instructions
<https://docs.scipy.org/doc/scipy/reference/building/linux.html>`_.

Windows
-------
Expand Down
26 changes: 0 additions & 26 deletions sklearn/_build_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from distutils.version import LooseVersion
import contextlib

from numpy.distutils.system_info import get_info

from .openmp_helpers import check_openmp_support


Expand All @@ -20,30 +18,6 @@
CYTHON_MIN_VERSION = '0.28.5'


def get_blas_info():
def atlas_not_found(blas_info_):
def_macros = blas_info.get('define_macros', [])
for x in def_macros:
if x[0] == "NO_ATLAS_INFO":
# if x[1] != 1 we should have lapack
# how do we do that now?
return True
if x[0] == "ATLAS_INFO":
if "None" in x[1]:
# this one turned up on FreeBSD
return True
return False

blas_info = get_info('blas_opt', 0)
if (not blas_info) or atlas_not_found(blas_info):
cblas_libs = ['cblas']
blas_info.pop('libraries', None)
else:
cblas_libs = blas_info.pop('libraries', [])

return cblas_libs, blas_info


def build_from_c_and_cpp_files(extensions):
"""Modify the extensions to build from the .c and .cpp files.
Expand Down
4 changes: 0 additions & 4 deletions sklearn/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@

def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info
import numpy

# needs to be called during build otherwise show_version may fail sometimes
get_info('blas_opt', 0)

libraries = []
if os.name == 'posix':
libraries.append('m')
Expand Down
33 changes: 0 additions & 33 deletions sklearn/utils/_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,49 +70,16 @@ def get_version(module):
return deps_info


def _get_blas_info():
"""Information on system BLAS
Uses the `scikit-learn` builtin method
:func:`sklearn._build_utils.get_blas_info` which may fail from time to time
Returns
-------
blas_info: dict
system BLAS information
"""
from .._build_utils import get_blas_info

cblas_libs, blas_dict = get_blas_info()

macros = ['{key}={val}'.format(key=a, val=b)
for (a, b) in blas_dict.get('define_macros', [])]

blas_blob = [
('macros', ', '.join(macros)),
('lib_dirs', ':'.join(blas_dict.get('library_dirs', ''))),
('cblas_libs', ', '.join(cblas_libs)),
]

return dict(blas_blob)


def show_versions():
"Print useful debugging information"

sys_info = _get_sys_info()
deps_info = _get_deps_info()
blas_info = _get_blas_info()

print('\nSystem:')
for k, stat in sys_info.items():
print("{k:>10}: {stat}".format(k=k, stat=stat))

print('\nBLAS:')
for k, stat in blas_info.items():
print("{k:>10}: {stat}".format(k=k, stat=stat))

print('\nPython deps:')
for k, stat in deps_info.items():
print("{k:>10}: {stat}".format(k=k, stat=stat))
3 changes: 1 addition & 2 deletions sklearn/utils/tests/test_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def test_get_deps_info():
assert 'joblib' in deps_info


def test_show_versions_with_blas(capsys):
def test_show_versions(capsys):
show_versions()
out, err = capsys.readouterr()
assert 'python' in out
assert 'numpy' in out
assert 'BLAS' in out

0 comments on commit 01a140a

Please sign in to comment.