numpy AMD Ryzen 5950X慢速,MKL 2020.0和MKL_DEBUG_CPU_TYPE=5

niknxzdl  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(130)

我刚买了一台装有Ryzen 5950 x的PC,它在Matlab 2020 b上运行得非常快,通过检查bench命令的结果。
我按照网上的建议,将MKL_DEBUG_CPU_TYPE=5全局设置为MKL 2020.0。我通过anaconda安装了python 3.8.5,numpy 1.20.0
当我在5950 x上使用下面的代码尝试numpy时,平均花费了28秒。我有另一台电脑与英特尔i7-8700,它只需要0.66秒
有人能告诉我为什么吗或者我应该安装BLAS而不是MKL?

import numpy as np
import os
from time import time

print(os.environ.get('MKL_DEBUG_CPU_TYPE')) # it should print 5
# Let's take the randomness out of random numbers (for reproducibility)
np.random.seed(0)

size = 4096
A, B = np.random.random((size, size)), np.random.random((size, size))
C, D = np.random.random((size * 128,)), np.random.random((size * 128,))
E = np.random.random((int(size / 2), int(size / 4)))
F = np.random.random((int(size / 2), int(size / 2)))
F = np.dot(F, F.T)
G = np.random.random((int(size / 2), int(size / 2)))

N = 5
t = time()
for i in range(N):
    np.dot(A, B)
delta = time() - t
print('Dotted two %dx%d matrices in %0.2f s.' % (size, size, delta / N))
mzaanser

mzaanser1#

安装intel-oneapi-mkl-2021。对ryzen的支持嵌入在里面。你不必写MKL_DEBUG_...
你可以点击链接:intel-oneapi

相关问题