我正在尝试使用Numba并访问GPU以加速代码,但出现以下错误:
in jit raise NotImplementedError("bounds checking is not supported for CUDA")
NotImplementedError: bounds checking is not supported for CUDA
[我看到有人提出了另一个问题,但没有完全指明或回答here。当我看到矢量化代码(y = corr*x + np.sqrt(1.-corr**2)*z
)不起作用(相同错误)时,我实现了2-for循环。我也尝试使用选项boundscheck
,但这并没有改变结果。未指定target
时未出现错误,因为它会自动出现在CPU上(我想)。
import numpy as np
from numba import jit
N = int(1e8)
@jit(nopython=True, target='cuda', boundscheck=False)
def Brownian_motions(T, N, corr):
x = np.random.normal(0, 1, size=(T,N))
z = np.random.normal(0, 1, size=(T,N))
y = np.zeros(shape=(T,N))
for i in range(T):
for j in range(N):
y[i,j] = corr*x[i,j] + np.sqrt(1.-corr**2)*z[i,j]
return(x,y)
x, y = Brownian_motions(T = 500, N = N, corr = -0.45)
您能帮我吗? Python是3.7.6,Numba是0.48.0。
@
中删除@jit
来做到这一点>