手动安装
sudo rm -rf /usr/local/lib/python2.7/site-packages/numpy/ sudo rm -rf /usr/local/lib/python2.7/site-packages/numpy-*.egg*sudo rm -rf /usr/local/bin/f2py
pip安装
sudo rm -rf /usr/local/lib/python2.7/dist-packages/numpy/ sudo rm -rf /usr/local/lib/python2.7/dist-packages/numpy-*.egg*sudo rm -rf /usr/local/bin/f2py
export BLAS=~/.local/lib/libopenblas.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib/
30down voteaccepted | I just compiled numpy inside a virtualenv with OpenBLAS integration, and it seems to be working ok. This was my process: 创新互联公司-成都网站建设公司,专注网站设计、网站制作、网站营销推广,域名注册,网页空间,网站托管运营有关企业网站制作方案、改版、费用等问题,请联系创新互联公司。Compile OpenBlas : git clone git://github.com/xianyi/OpenBLAS
cd OpenBLAS && make FC=gfortran
sudo make PREFIX=/opt/OpenBLAS install
sudo ldconfig Grab the numpy source code: git clone https://github.com/numpy/numpy
cd numpy Copy site.cfg.example to site.cfg and edit the copy: cp site.cfg.example site.cfg
nano site.cfg Uncomment these lines: ....
[openblas]
libraries = openblas
library_dirs = /opt/OpenBLAS/lib
include_dirs = /opt/OpenBLAS/include
.... Check configuration, build, install (optionally in a virutalenv ) python setup.py config The output should look something like this: ...
openblas_info:
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/opt/OpenBLAS/lib']
language = f77
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/opt/OpenBLAS/lib']
language = f77
... Then just build and install: python setup.py build && python setup.py install Optional: you can use this script to test performance for different thread counts. OMP_NUM_THREADS=1 python build/test_numpy.py
FAST BLAS
version: 1.8.0.dev-27690e3
maxint: 9223372036854775807
dot: 0.100896406174 sec
OMP_NUM_THREADS=8 python test_numpy.py
FAST BLAS
version: 1.8.0.dev-27690e3
maxint: 9223372036854775807
dot: 0.0660264015198 sec
There seems to be a noticeable improvement in performance for higher thread counts. However, I haven't tested this very systematically, and it's likely that for smaller matrices the additional overhead would outweigh the performance benefit from a higher thread count.
share|improve this answer |
edited Jul 3 at 15:16
|
answered Jan 18 '13 at 2:50
ali_m 7,0352055 |
|
|
|
OMP_NUM_THREADS=7 python test.py
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
print "version:", numpy.__version__
print "maxint:", sys.maxint
print
x = numpy.random.random((1000,1000))
setup = "import numpy; x = numpy.random.random((1000,1000))"
count = 5
t = timeit.Timer("numpy.dot(x, x.T)", setup=setup)
print "dot:", t.timeit(count)/count, "sec"
分享文章:numpydelete-创新互联
标题链接:
http://shouzuofang.com/article/dghehs.html