<div dir="ltr">Well, here is the question that started this all.  In the slow environment, blas seems to be there and work well, but numpy doesn't use it! <br><br>In [1]: import time, numpy, scipy<br><br>In [2]: from scipy import linalg<br><br>In [3]: n=1000<br><br>In [4]: A = numpy.random.rand(n,n)<br><br>In [5]: B = numpy.random.rand(n,n)<br><br>In [6]: then = time.time(); C=scipy.dot(A,B); print time.time()-then<br>7.62005901337<br><br>In [7]: begin = time.time(); C=linalg.blas.dgemm(1.0,A,B);print time.time() - begin<br>0.325305938721<br><br>In [8]: begin = time.time(); C=linalg.blas.ddot(A,B);print time.time() - begin<br>0.0363020896912<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 20, 2015 at 4:09 AM, Sebastian Berg <span dir="ltr"><<a href="mailto:sebastian@sipsolutions.net" target="_blank">sebastian@sipsolutions.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fr, 2015-06-19 at 16:19 -0500, Elliot Hallmark wrote:<br>
> Debian Sid, 64-bit.  I was trying to fix the problem of np.dot running<br>
> very slow.<br>
><br>
><br>
> I ended up uninstalling numpy, installing libatlas3-base through<br>
> apt-get and re-installing numpy.  The performance of dot is greatly<br>
> improved!  But I can't tell from any other method whether numpy is set<br>
> up correctly.  Consider comparing the faster one to another in a<br>
> virtual env that is still slow:<br>
><br>
<br>
</span>Not that I really know this stuff, but one thing to be sure is probably<br>
checking `ldd /usr/lib/python2.7/dist-packages/numpy/core/_dotblas.so`.<br>
That is probably silly (I really never cared to learn this stuff), but I<br>
think it can't go wrong....<br>
<br>
About the other difference. Aside from CPU, etc. differences, I expect<br>
you got a newer numpy version then the other user. Not sure which part<br>
got much faster, but there were for example quite a few speedups in the<br>
code converting to array, so I expect it is very likely that this is the<br>
reason.<br>
<span class="HOEnZb"><font color="#888888"><br>
- Sebastian<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> ###<br>
><br>
> fast one<br>
> ###<br>
><br>
> In [1]: import time, numpy<br>
><br>
> In [2]: n=1000<br>
><br>
> In [3]: A = numpy.random.rand(n,n)<br>
><br>
> In [4]: B = numpy.random.rand(n,n)<br>
><br>
> In [5]: then = time.time(); C=numpy.dot(A,B); print time.time()-then<br>
> 0.306427001953<br>
><br>
> In [6]: numpy.show_config()<br>
> blas_info:<br>
>     libraries = ['blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
> lapack_info:<br>
>     libraries = ['lapack']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
> atlas_threads_info:<br>
>   NOT AVAILABLE<br>
> blas_opt_info:<br>
>     libraries = ['blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
>     define_macros = [('NO_ATLAS_INFO', 1)]<br>
> atlas_blas_threads_info:<br>
>   NOT AVAILABLE<br>
> openblas_info:<br>
>   NOT AVAILABLE<br>
> lapack_opt_info:<br>
>     libraries = ['lapack', 'blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
>     define_macros = [('NO_ATLAS_INFO', 1)]<br>
> atlas_info:<br>
>   NOT AVAILABLE<br>
> lapack_mkl_info:<br>
>   NOT AVAILABLE<br>
> blas_mkl_info:<br>
>   NOT AVAILABLE<br>
> atlas_blas_info:<br>
>   NOT AVAILABLE<br>
> mkl_info:<br>
>   NOT AVAILABLE<br>
><br>
> ###<br>
><br>
> slow one<br>
> ###<br>
><br>
> In [1]: import time, numpy<br>
><br>
> In [2]: n=1000<br>
><br>
> In [3]: A = numpy.random.rand(n,n)<br>
><br>
> In [4]: B = numpy.random.rand(n,n)<br>
><br>
> In [5]: then = time.time(); C=numpy.dot(A,B); print time.time()-then<br>
> 7.88430500031<br>
><br>
> In [6]: numpy.show_config()<br>
> blas_info:<br>
>     libraries = ['blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
> lapack_info:<br>
>     libraries = ['lapack']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
> atlas_threads_info:<br>
>   NOT AVAILABLE<br>
> blas_opt_info:<br>
>     libraries = ['blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
>     define_macros = [('NO_ATLAS_INFO', 1)]<br>
> atlas_blas_threads_info:<br>
>   NOT AVAILABLE<br>
> openblas_info:<br>
>   NOT AVAILABLE<br>
> lapack_opt_info:<br>
>     libraries = ['lapack', 'blas']<br>
>     library_dirs = ['/usr/lib']<br>
>     language = f77<br>
>     define_macros = [('NO_ATLAS_INFO', 1)]<br>
> atlas_info:<br>
>   NOT AVAILABLE<br>
> lapack_mkl_info:<br>
>   NOT AVAILABLE<br>
> blas_mkl_info:<br>
>   NOT AVAILABLE<br>
> atlas_blas_info:<br>
>   NOT AVAILABLE<br>
> mkl_info:<br>
>   NOT AVAILABLE<br>
><br>
> #####<br>
><br>
><br>
> Further, in the following comparison between Cpython and converting to<br>
> numpy array for one operation, I get Cpython being faster by the same<br>
> amount in both environments.  But another user got numpy being faster.<br>
><br>
> In [1]: import numpy as np<br>
><br>
> In [2]: pts = range(100,1000)<br>
><br>
> In [3]: pts[100] = 0<br>
><br>
> In [4]: %timeit pts_arr = np.array(pts); mini = np.argmin(pts_arr)<br>
> 10000 loops, best of 3: 129 µs per loop<br>
><br>
> In [5]: %timeit mini = sorted(enumerate(pts))[0][1]<br>
> 10000 loops, best of 3: 89.2 µs per loop<br>
><br>
> The other user got<br>
><br>
> In [29]: %timeit pts_arr = np.array(pts); mini = np.argmin(pts_arr)<br>
> 10000 loops, best of 3: 37.7 µs per loop<br>
><br>
> In [30]: %timeit mini = sorted(enumerate(pts))[0][1]<br>
> 10000 loops, best of 3: 69.2 µs per loop<br>
><br>
><br>
> And I can't help but wonder if there is further configuration I need to make numpy faster, or if this is just a difference between out machines<br>
> In the future, should I ignore show_config() and just do this dot<br>
> product test?<br>
><br>
><br>
> Any guidance would be appreciated.<br>
><br>
><br>
> Thanks,<br>
><br>
>   Elliot<br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>