Openblas does not link to Scipy

蹲街弑〆低调 提交于 2019-12-08 01:39:39

问题


I am currently running scipy on Debian Jessie. I have installed scipy from apt-get. I have also installed blas and lapack from apt

sudo apt-get install python-scipy libblas-dev libatlas-dev

Then I have compile openblas on my machine and install it in the default path: /opt/OpenBLAS/

I have updated the alternatives, and everything seem to be fine:

 sudo update-alternatives --list libblas.so.3
/opt/OpenBLAS/lib/libopenblas.so

sudo update-alternatives --config liblapack.so.3
Il existe 2 choix pour l'alternative liblapack.so.3 (qui fournit /usr/lib/liblapack.so.3).

  Sélection   Chemin                          Priorité  État
------------------------------------------------------------
  0            /usr/lib/lapack/liblapack.so.3   40        mode automatique
* 1            /usr/lib/lapack/liblapack.so.3   40        mode manuel
  2            /usr/lib/liblapack.so            40        mode manuel

However, when I am computing dot product with scipy it seems to not use Openblas, while if I am calling directly the dgemm function it seems to be good. I use the following code:

import numpy as np
import scipy as sp
from scipy import linalg
import time
from scipy.linalg.blas import dsyrk,dsymm,dgemm

n = 1000

#  Data generation
x = sp.random.rand(n,n)
x += x.T
x /= 2


# Dot product
ts=time.time()
xn = np.dot(x,x)
print 'numpy dot product ',time.time()-ts

ts=time.time()
xs = sp.dot(x,x)
print 'scipy dot product ',time.time()-ts

ts=time.time()
xss = dgemm(1.0,x,x)
print 'openblas dot product ',time.time()-ts

# eig
ts=time.time()
[E,v]=np.linalg.eigh(xss)
print 'numpy eig ',time.time()-ts

ts=time.time()
[E,v]=linalg.eigh(xss)
print 'scipy eig ',time.time()-ts
python test_openblas.py
numpy dot product  2.31659698486
scipy dot product  2.34038615227
openblas dot product  0.0457999706268
numpy eig  2.27925086021
scipy eig  0.384080886841

All my programs use sp.dot() rather than dgemm and sp.dot() works well on other machines (ubuntu or debian ones). If someone has some inputs/solutions, it would be very nice ! Any help too !

来源:https://stackoverflow.com/questions/44161342/openblas-does-not-link-to-scipy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!