[Numpy-discussion] Performance degradation when installing Numpy and Python not from packaging system?

Bin Huang bin.arthur at gmail.com
Wed May 8 13:47:52 EDT 2013

Hi list,

I have observed slowdown if Numpy and Python are installed manually (i.e.
not from packaging system). The slowdown can be significant when problem
size is large. I wish someone in this mailing list can give me some hints
on this issue. I also post performance results and my source code here.

My platform is a 12-core dual-socket SMP machine running Ubuntu (Linux
kernel 3.2.0). On this platform, I have two sets of installations. One is
pre-installed Python 2.7.3 and Numpy 1.6.1 installed with 'apt-get'. The
other is Python 2.7.3 and Numpy 1.6.1 both compiled freshly from official
tarball release by myself.

In order to compare performance, I wrote a piece of code that simply
performs matrix-matrix multiplication using one of Numpy's functions. The
source code is listed as follows:

*if __name__ == "__main__":
    import numpy, random, time
    import sys

    size = int(sys.argv[1]) # For simplicity, we only test square matrix

    matrix_a = numpy.matrix(numpy.random.randn(size,size))
    matrix_b = numpy.matrix(numpy.random.randn(size,size))

    start_time = time.time()
    result = numpy.dot(matrix_a, matrix_b)
    print '%0.3f ms' % ((time.time() - start_time)*1000.0)*

I ran this code with both pre-installed Python and compiled Python. Here is
performance numbers I got:

Problem size    Pre-installed Python       Compiled Python/Numpy
256x256           14.165 ms                     44.538 ms
512x512           109.330 ms                   347.143 ms
1024x1024       867.936 ms                    8975.016 ms
2048x2048       7755.084 ms                  84713.997 ms

Here are commands I used to compile Python and Numpy:

a) ~/python2.7.3$ ./configure --prefix=MY_LOCAL_DIR
b) ~/python2.7.3$ make
c) ~/python2.7.3$ make install
e) ~/numpy-1.6.1$ MY_LOCAL_DIR/bin/python setup.py build
f) ~/numpy-1.6.1$ MY_LOCAL_DIR/bin/python setup.py install

Any ideas? Thanks in advance.

Bin Huang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130508/4e26a972/attachment.html>

More information about the NumPy-Discussion mailing list