blas

Numpy Pure Functions for performance, caching

人盡茶涼 提交于 2019-11-26 22:54:12
I'm writing some moderately performance critical code in numpy. This code will be in the inner most loop, of a computation that's run time is measured in hours. A quick calculation suggest that this code will be executed up something like 10^12 times, in some variations of the calculation. So the function is to calculate sigmoid(X) and another to calculate its derivative (gradient). Sigmoid has the property that for y=sigmoid(x), dy/dx= y(1-y) In python for numpy this looks like: sigmoid = vectorize(lambda(x): 1.0/(1.0+exp(-x))) grad_sigmoid = vectorize(lambda (x): sigmoid(x)*(1-sigmoid(x)))

Find out if/which BLAS library is used by Numpy

我与影子孤独终老i 提交于 2019-11-26 20:13:38
问题 I use numpy and scipy in different environments (MacOS, Ubuntu, RedHat). Usually I install numpy by using the package manager that is available (e.g., mac ports, apt, yum). However, if you don't compile Numpy manually, how can you be sure that it uses a BLAS library? Using mac ports, ATLAS is installed as a dependency. However, I am not sure if it is really used. When I perform a simple benchmark, the numpy.dot() function requires approx. 2 times the time than a dot product that is computed

How to check BLAS/LAPACK linkage in NumPy and SciPy?

断了今生、忘了曾经 提交于 2019-11-26 19:20:47
I am builing my numpy/scipy environment based on blas and lapack more or less based on this walk through. When I am done, how can I check, that my numpy/scipy functions really do use the previously built blas/lapack functionalities? rabra What you are searching for is this: system info I compiled numpy/scipy with atlas and i can check this with: import numpy.distutils.system_info as sysinfo sysinfo.get_info('atlas') Check the documentation for more commands. The method numpy.__config__.show() outputs information about linkage gathered at build time. My output looks like this. I think it means

calling dot products and linear algebra operations in Cython?

南楼画角 提交于 2019-11-26 18:45:20
I'm trying to use dot products, matrix inversion and other basic linear algebra operations that are available in numpy from Cython. Functions like numpy.linalg.inv (inversion), numpy.dot (dot product), X.t (transpose of matrix/array). There's a large overhead to calling numpy.* from Cython functions and the rest of the function is written in Cython, so I'd like to avoid this. If I assume users have numpy installed, is there a way to do something like: #include "numpy/npy_math.h" as an extern , and call these functions? Or alternatively call BLAS directly (or whatever it is that numpy calls for

Numpy Pure Functions for performance, caching

狂风中的少年 提交于 2019-11-26 09:11:39
问题 I\'m writing some moderately performance critical code in numpy. This code will be in the inner most loop, of a computation that\'s run time is measured in hours. A quick calculation suggest that this code will be executed up something like 10^12 times, in some variations of the calculation. So the function is to calculate sigmoid(X) and another to calculate its derivative (gradient). Sigmoid has the property that for y=sigmoid(x), dy/dx= y(1-y) In python for numpy this looks like: sigmoid =

calling dot products and linear algebra operations in Cython?

北城余情 提交于 2019-11-26 05:27:17
问题 I\'m trying to use dot products, matrix inversion and other basic linear algebra operations that are available in numpy from Cython. Functions like numpy.linalg.inv (inversion), numpy.dot (dot product), X.t (transpose of matrix/array). There\'s a large overhead to calling numpy.* from Cython functions and the rest of the function is written in Cython, so I\'d like to avoid this. If I assume users have numpy installed, is there a way to do something like: #include \"numpy/npy_math.h\" as an

multithreaded blas in python/numpy

匆匆过客 提交于 2019-11-26 04:11:15
问题 I am trying to implement a large number of matrix-matrix multiplications in Python. Initially, I assumed that NumPy would use automatically my threaded BLAS libraries since I built it against those libraries. However, when I look at top or something else it seems like the code does not use threading at all. Any ideas what is wrong or what I can do to easily use BLAS performance? 回答1: Not all of NumPy uses BLAS, only some functions -- specifically dot() , vdot() , and innerproduct() and

Link ATLAS/MKL to an installed Numpy

99封情书 提交于 2019-11-26 03:56:16
问题 TL;DR how to link ATLAS/MKL to existing Numpy without rebuilding. I have used Numpy to calculate with the large matrix and I found that it is very slow because Numpy only use 1 core to do calculation. After doing a lot of search I figure that my Numpy does not link to some optimized library like ATLAS/MKL. Here is my config of numpy: >>>import numpy as np >>>np.__config__.show() blas_info: libraries = [\'blas\'] library_dirs = [\'/usr/lib\'] language = f77 lapack_info: libraries = [\'lapack\'

Why does multiprocessing use only a single core after I import numpy?

自古美人都是妖i 提交于 2019-11-26 01:34:51
问题 I am not sure whether this counts more as an OS issue, but I thought I would ask here in case anyone has some insight from the Python end of things. I\'ve been trying to parallelise a CPU-heavy for loop using joblib , but I find that instead of each worker process being assigned to a different core, I end up with all of them being assigned to the same core and no performance gain. Here\'s a very trivial example... from joblib import Parallel,delayed import numpy as np def testfunc(data): #

Compiling numpy with OpenBLAS integration

北城余情 提交于 2019-11-25 23:53:44
问题 I am trying to install numpy with OpenBLAS , however I am at loss as to how the site.cfg file needs to be written. When the installation procedure was followed the installation completed without errors, however there is performance degradation on increasing the number of threads used by OpenBLAS from 1 (controlled by the environment variable OMP_NUM_THREADS). I am not sure if the OpenBLAS integration has been perfect. Could any one provide a site.cfg file to achieve the same. P.S.: OpenBLAS