Python:与MacOS相比,Windows10上的Scipy非常慢

问题描述 投票:1回答:1

强调texti尝试在我的两个分区上的macbook pro 15上执行一个简单的python程序:MacOS Mojave和Windows 10。

我使用spsolve函数来解决某些矩阵上的稀疏线性系统,我发现使用相同矩阵的相同代码在Windows上比Macos慢得多。

例如:

  • 矩阵1 - > MacOs:29秒/ Windows:377秒

在MacOS上,当我执行这些计算时,处理器全速运行,我觉得风扇变强了。在Windows上,这不会发生,处理器保持在20%。

我在两个系统上都使用Python 3 64bit。

from scipy import array, linalg, dot
import scipy.io as sio
import numpy as np
import time
from scipy.sparse.linalg import spsolve

matrix_names = ['cfd1']

for matrice in matrix_names:
    mat = sio.loadmat('/matrix_path/%s' %matrice)

    A = mat['Problem']['A']
    A=A[0][0]
    matrix_size = np.shape(A)[0]
    xe = np.ones(matrix_size)
    b = A * xe

    start = time.time()
    X = spsolve(A, b) 
    end = time.time()

    print("Times %.6f sec" %(end-start))

慢功能是

X = spsolve(A, b)
python windows macos performance scipy
1个回答
0
投票

我发现了问题。

默认情况下,Windows上没有实现MKL库。我不确定在MacOS上它是集成的,但是在Windows上使用Anaconda(使用MKL库实现Scipy),Python文件的执行速度与MacOS一样快。

© www.soinside.com 2019 - 2024. All rights reserved.