[SciPy-user] optimizing numpy on Linux?

Robert Kern robert.kern at gmail.com
Sat May 17 22:06:17 EDT 2008


On Sat, May 17, 2008 at 8:48 PM, David Warde-Farley <dwf at cs.toronto.edu> wrote:
> Hi,
>
> I'm going to be deploying an application that makes extensive use of
> numpy and scipy on a custom-built quad core machine running Linux.
> We're at the moment running Ubuntu Server edition.
>
> I've installed atlas3-base and the header packages via apt, and am
> about to start compiling numpy and scipy from source. The trouble is,
> I'd like it to be as fast as humanly possible, and don't know the
> first thing about tweaking a Linux system for that. Is it a matter of
> compiling and installing an optimized BLAS "by hand"?

If your application heavily uses linear algebra operations, yes, this
would help. In particular, the ATLAS in Ubuntu is fairly old and is
missing many optimizations for newer CPUs (in addition to being a
generic build that won't take advantage of your precise
configuration). However, in another thread, Xavier Gnata has been
having trouble doing exactly this. I haven't built numpy against a
recent ATLAS myself for some time, so I don't know what the problem
is. If you get it working, please let him know how you did it and
update the wiki page for installing on Linux.

> Are there any
> strategies for benchmarking a numpy install?

Find the hotspots in your application through profiling first,
identify non-numpy things that you could do to speed those up,
identify the numpy operations that affect the remaining hotspots, then
write benchmarks targeting those specific features. If these
operations are very small (a[0]), then the timeit module is fairly
useful. If the operations are large (> 1s) or use a lot of memory
(linalg.solve(bigmatrix)), don't use timeit; only do one execution
instead of looping. IPython has some good utility functions for timing
such functions using resource.getrusage() which will record just the
time your actual code spent on the CPU rather than the wall-clock time
between when you started and ended.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the SciPy-User mailing list