Numpy/Scipy 与 Openblas

Numpy/Scipy 与 Openblas

我一直在尝试安装 Numpy/Scipy 并允许它们都使用 Openblas。我一直在遵循各种指南,但一直在使用这个最近。指南的最后,有几个测试来检查 Numpy/Scipy 的速度。测试如下:

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"


import timeit

setup = "import numpy;\
        import scipy.linalg as linalg;\
        x = numpy.random.random((1000,1000));\
        z = numpy.dot(x, x.T)"
count = 5

t = timeit.Timer("linalg.cholesky(z, lower=True)", setup=setup)
print "cholesky:", t.timeit(count)/count, "sec"

t = timeit.Timer("linalg.svd(z)", setup=setup)
print "svd:", t.timeit(count)/count, "sec"

我的测试结果显示slow blas正在使用。但是我的测试结果与指南的测试结果一致。我的感觉是 Numpy/Scipy 都在使用 openblas,但由于没有文件(它没有)slow blas而被打印。我如何进一步判断 openblas 是否真的被使用了?numpy.core_dotblas

指南的测试结果:

NumPy
dot: 0.0569217920303 sec

SciPy
cholesky: 0.0204758167267 sec
svd: 0.81153883934 sec

我的测试结果:

slow blas
version: 1.10.0.dev0+a419ebb
maxint: 9223372036854775807

dot: 0.0185512065887 sec
cholesky: 0.0125649929047 sec
svd: 0.293599033356 sec

相关内容