[Numpy-discussion] Problems when using ACML with numpy

Thomas Unterthiner thomas_unterthiner at web.de
Fri May 11 18:54:47 EDT 2012


Hi there!

I'm having troubles getting numpy to work with ACML.  I'm running Ubuntu 
12.04 on an x86-64 system and use acml 5.1.0.

On my first try, I installed numpy/scipy from the official ubuntu 
repository, then just changed the symlink to the blas/lapack libraries 
of my system to use acml. i.e. I did:

ln -s /usr/lib/liblapack.so.3gf  
/opt/acml5.1.0/gfortran64_fma4/lib/libacml.so
ln -s /usr/lib/libblas.so.3gf  /opt/acml5.1.0/gfortran64_fma4/lib/libacml.so

This method worked perfectly fine for Octave. However with numpy the 
following code will always run into what seems to be an endless loop:

import numpy as np
import time
a = np.random.randn(5000, 5000)
t0 = time.clock()
b = np.dot(a, a)
t1 = time.clock()
print t1 - t0


The process will have 100% CPU usage and will not show any activity 
under strace. A gdb backtrace looks as follows:

(gdb) bt
#0  0x00007fdcc000e524 in ?? ()
    from /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so
#1  0x00007fdcc008bcb9 in ?? ()
    from /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so
#2  0x00007fdcc00a304d in ?? ()
    from /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so
#3  0x000000000042a485 in PyEval_EvalFrameEx ()
#4  0x00000000004317f2 in PyEval_EvalCodeEx ()
#5  0x000000000054bd50 in PyRun_InteractiveOneFlags ()
#6  0x000000000054c045 in PyRun_InteractiveLoopFlags ()
#7  0x000000000054ce9f in Py_Main ()
#8  0x00007fdcc0e7976d in __libc_start_main ()
    from /lib/x86_64-linux-gnu/libc.so.6


Curiously enough, when changing the matrix-dimensions from 5000x5000 to 
500x500, all is good and the code executes in 0.32 seconds. (As a 
reference: the 5000x5000 matrix multiply takes 65 seconds in octave with 
ATLAS and 10 seconds with ACML, so the problem is not that the 
matrix-multiply just takes too long).


I then tried compiling  numpy-1.6.1 myself, doing:

tar xzf numpy-1.6.1.tar.gz
cd numpy-1.6.1/
export CFLAGS="-O3 -march=native"
export CXXFLAGS="-O3 -march=native"
export FFLAGS="-O3 -march=native"
export FCFLAGS="-O3 -march=native"
export LDFLAGS="-O3"
export BLAS=/opt/acml5.1.0/gfortran64_fma4/lib/libacml.so
export LAPACK=/opt/acml5.1.0/gfortran64_fma4/lib/libacml.so
export ATLAS=None
python setup.py build

This worked (apart from a missing '-shared' flag when linking 
lapack_lite.so, which I then had to link by hand by adding the flag), 
however the error persisted. The same with numpy-1.6.2rc1.

Fromt here I don't know how to proceed. Any help would be greatly 
appreciated :)


Cheers


Thomas




More information about the NumPy-Discussion mailing list