Python CuPy를 활용한 Matrix 연산 최적화
import cupy as cp import numpy as np import time print("Current Device : ", cp.cuda.runtime.getDeviceCount()) N = 10000 a = cp.random.rand(N,N) b = cp.random.rand(N,N) c = np.random.rand(N,N) d = np.random.rand(N,N) t1 = time.time() cp.matmul(a,b,out=None) t2 = time.time() t3 = time.time() np.matmul(c,d,out=None) t4 = time.time() print(f"CP : N{N} Time:", t2-t1) print(f"NP : N{N} Time:", t4-t3) ..
더보기