NumPy

Getting a fast NumPy on Debian

First test the one you got. How fast is it?

Test

python -c 'import numpy; numpy.show_config()'
from numpy import *
import time
A = random.random((4000,4000))
B = random.random((4000,4000))
t = time.time(); dot(A,B); print time.time()-t

Install with OpenBlas

OpenBlas? can use multiple cores -- that's great (can lead to some problems with SciPy? though).

Install:

apt-get install libopenblas-base

Check it is used:

# check alternatives
update-alternatives --list libblas.so.3

# set OpenBlas
sudo update-alternatives --set libblas.so.3 /usr/lib/openblas-base/libblas.so.3

Force single-thread

If your application is already multi-threaded, it will conflict with OpenBLAS multi-threading. 
Thus, you must set OpenBLAS to use single thread as following.
export OPENBLAS_NUM_THREADS=1 in the environment variables.

Source: https://github.com/xianyi/OpenBLAS/wiki/Faq

You might need to rebuild numpy

# create and source environment
virtualenv --system-site-packages MYENV
source MYENV/bin/activate

# rebuild numpy
pip install --upgrade numpy

DEPRECATED: Building ATLAS

Download and unpack (also get lapack in a fitting version), then in ATLAS (with fitting values):

mkdir BUILDDIR
cd BUILDDIR
../configure -b 64 -Fa alg -fPIC --prefix=/home/cbo/opt/atlas -D c -DPentiumCPS=3492 --with-netlib-lapack-tarfile=/home/cbo/scratch/lapack-3.4.1.tgz 
make build
make check
make ptcheck
make time
make install

cpu throttling

Disabling cpu throttling is not easy on an Intel Core processor... I put the cpus in "performance", with something like:

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

For all cpus [0123].

But to get Atlas to work, requires hacking ATLAS/CONFIG/src/config.c file, to make the "ProbeCPUThrottle?" function return 0. (http://sourceforge.net/p/math-atlas/support-requests/857/)

Doc: