Wie kann man Intel MKL in Numpy Python aktivieren und deaktivieren?
Posted: 11 Apr 2025, 20:47
Ich möchte die Multiplikation der Numpy-Matrix und die Eigenschaftsleistung mit Intel MKL und ohne Intel MKL testen und vergleichen. Zersetzungen.
Code: Select all
import numpy as np
from time import time
def matrix_mul(size, n=100):
# reference: https://markus-beuckelmann.de/blog/boosting-numpy-blas.html
np.random.seed(112)
a, b = np.random.random((size, size)), np.random.random((size, size))
t = time()
for _ in range(n):
np.dot(a, b)
delta = time() - t
print('Dotted two matrices of size %dx%d in %0.4f ms.' % (size, size, delta / n * 1000))
def eigen_decomposition(size, n=10):
np.random.seed(112)
a = np.random.random((size, size))
t = time()
for _ in range(n):
np.linalg.eig(a)
delta = time() - t
print('Eigen decomposition of size %dx%d in %0.4f ms.' % (size, size, delta / n * 1000))
#Obtaining computation times:
for i in range(20):
eigen_decomposition(500)
for i in range(20):
matrix_mul(500)