【发布时间】:2020-04-23 17:38:36
【问题描述】:
我正在尝试使用 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。
【问题讨论】:
-
Cuda 版本为 10.2。另一方面,如果我尝试使用
@vectorize(['UniTuple(float64, 2)(float64, float64, float64)'], target='cuda')作为装饰器,我得到的错误是Unknown attribute 'normal' of type Module。
标签: python python-3.x jit numba