Numpy and Scipy and their Lapack and Atlas dependencies - performance

I'm trying to install python numpy from source with libraries Lapack and Atlas. I have realized that Atlas itself contains lapack library. However if I compile it(atlas only), it has 0.5 MB. When Netlib Lapack is deployed than the library liblapac.a has more than 13 MB. This leads me to following questions:
Questions regarding numpy/scipy:
can i install numpy/scipy only with netlib's Lapack, or only with Atlas lib?
(if answer for 1 is yes) if only Atlas lib is installed (no netlib's Lapack) -are there any disadvantages (performance, functions unavailable,...)
is there any performance review how numpy/scipy are doing w/out Lapack/Atlas installed?
Numpy, or Scipy does use more Atlas/Lapack? is there any significant difference?
thanks!

ATLAS is not a full LAPACK implementation. It only provides a few routines that are optimized.
This ATLAS page explains how to build full LAPACK that also uses ATLAS.
From the page:
ATLAS natively provides only a relative handful of the routines which comprise LAPACK.
The SciPy Homepage tells you that you need LAPACK for SciPy, but not for numpy:
Before building, you will also need to install packages that NumPy and SciPy depend on
BLAS and LAPACK libraries (optional but strongly recommended for NumPy, required for SciPy): typically ATLAS + LAPACK, or MKL, or ACML
[...]
To summarize, if you want SciPy, you need LAPACK. If you want a faster LAPACK, you might want to install ATLAS, too. If you only want numpy, LAPACK is not required, but considered a good idea by the SciPy people.

Related

Should I install Lapack and Eigen for OpenCV?

I'm trying to build OpenCV (4.5.1) from source, from the CMake-GUI output, there are 2 third-party libraries displayed as NO.
Other third-party libraries:
Intel IPP: 2020.0.0 Gold [2020.0.0]
at: C:/Users/opencv-4.5.1/_build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2020.0.0)
at: C:/Users/opencv-4.5.1/_build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
I want best performance of OpenCV, so I'd like to check what's the performance gain if I install Lapack or Eigen?

Is it possible to package python binary extension into wheels targeted for different hardware?

Does python's pip allow to distribute binary extensions as separate wheels for different hardware? For instance one version for arm, another for ivybridge, another for haswell?
I know one can prepare pip package which can build itself from sources during install, but this question is about a situation when a package lacks such facility.
EDIT: I am asking from a developer/maintainer perspective.

Can Armadillo be used on clusters?

From the Armadillo install instructions:
If you are using sparse matrices, also install ARPACK and SuperLU.
Caveat: only SuperLU version 4.3 can be used!
On the SuperLU site there are three versions available: SuperLU, SuperLU_MT and SuperLU_DIST. Since the requirement is version 4.3, does it mean that only the single threaded version can be linked to Armadillo? If so, it means, that for sparse matrices only single PCs can be used, I cannot make use of the cluster available at my university.

How to get all available install options for a port?

Basically I'd like to install opencv so that it makes use of tbb and boost with the complete source code. However I think I will need to know how to display all the available install options for a port. (Install options I mean "+sth" after a port name, is that how you call it?)
In my concrete example, my line starts like
sudo port install opencv +tbb +python27
but I am not sure how to get the dev and the boost options...
Any ideas how to display options? Or specifically for opencv?
Thanks!
In addition to the answer provided by Barnabas Szabolcs, I have also found the info command is helpful for finding more information about a port, including the available variants, but also provides other interesting bits of information, such as the software license, maintainers, etc.
port info opencv
The above command results in the following output (as of the current portfile):
opencv #3.0.0_1 (graphics, science)
Variants: contrib, dc1394, debug, eigen, java, opencl, openni,
python27, python34, qt4, qt5, tbb, universal, vtk
Description: OpenCV is a library that is mainly aimed at real time
computer vision. Some example areas would be
Human-Computer Interaction (HCI), Object Identification,
Segmentation and Recognition, Face Recognition, Gesture
Recognition, Motion Tracking, Ego Motion, Motion
Understanding, Structure From Motion (SFM), and Mobile
Robotics.
Homepage: http://opencv.org
Extract Dependencies: unzip
Build Dependencies: cmake, pkgconfig
Library Dependencies: zlib, bzip2, libpng, jpeg, jasper, tiff, ilmbase, openexr,
ffmpeg
Platforms: darwin
License: BSD
Maintainers: stromnov#macports.org, openmaintainer#macports.org
Sorry, I have found it:
Port install options are called not options but variants. And the command is:
port variants opencv
in my case.
For those who care -- although in the code of opencv I have fond USING_BOOST flags -- there is no extra variant for boost support (perhaps it is automatic?).
My complete install line is
sudo port install opencv +debug +python27 +qt4 +tbb

What do the optional libraries in the OpenCV build provide?

I am trying to build OpenCV from source (latest SVN trunk) and there are several "optional" dependencies, which will amount to several gigabytes of downloading on their own, especially with the Qt Framework.
For example:
CUDA
GHOSTSCRIPT
MIKTEX
PYTHON
EIGEN
IPP
JASPER
JPEG
OPENEXR
OPENNI
PNG
QT
QT_OPENGL
TBB
TIFF
VIDEOINPUT
XIMEA
Can someone provide a list of what each of these external things provides - ranked by importance? (Sometimes subjective answers are the most insightful answers.) Which ones are built in the binary distribution?
Usually you can leave all the flags in default state unless you need to enable or disable some special features. All really important libraries are already there.
Options you listened can be split into several groups:
Image input/output
Actually OpenCV comes with a copy of these libraries for platforms where these libraries are missed (like Windows or Android).
TIFF
JASPER - jpeg2000 format
JPEG
PNG
OPENEXR - this one is not included into OpenCV
Video IO
VIDEOINPUT - video IO API for Windows platform. Since version 2.3.0 OpenCV embeds it and this flag is useful only to exclude videoinput library from build.
OPENNI - driver for Kinect
XIMEA - API for XIMEA cameras
Libraries of performance primitives
IPP - few dozens of OpenCV functions have IPP accelerated versions.
TBB - OpenCV has a number of functions parallelized with Intel TBB library.
EIGEN - some math functions (like SVD) can use power of Eigen library but OpenCV always provides alternative implementation.
GPU acceleration
CUDA - OpenCV comes with gpu module having a lot of functions accelerated with NVIDIA CUDA technology. If CUDA SDK is not found, then all functions degrade to CPU implementation.
Enhanced GUI
QT - OpenCV GUI functions (like imshow) has a QT version. Without QT they will default to native OS interfaces. (In case of Windows it will be WinAPI).
QT_OPENGL
Bindings to other languages
PYTHON - also build bindings for Python language
Building documentation
GHOSTSCRIPT - obsolete in 2.3.x (does not affect build)
MIKTEX - Windows only. Used to generate documentation in PDF format
Actually this is just a partial answer to your question. You have listened less than half of the options that can be set on OpenCV configuration step - other half is hidden because those options are not available for your platform.

Resources