nvcc编译失败 - pycuda

时间:2016-09-23 15:39:57

标签: python compiler-errors anaconda nvcc pycuda

我最近开始与Pycuda合作。我尝试执行一些代码,但是我尝试执行的所有代码都出现了类似的错误。

import pycuda.autoinit
import pycuda.driver as cuda
from pycuda.compiler import SourceModule
mod = SourceModule("""
__gloabal__ void adder(float * h_a,float * h_b,float * h_c)
{
    const int idx= blockDim.x*blockIdx.x+threadIdx.x;
    const int idy= blockDim.y*blockIdx.y+threadIdx.y;
    h_c[idx][idy]=h_a[idx][idy]+h_b[idx][idy];    
}
""")
adder=mod.get_function("adder")
h_a=numpy.random.randn(64,64)
h_a=h_a.astype(numpy.float32)
h_b=numpy.random.randn(64,64)
h_b=h_b.astype(numpy.float32)
h_c=numpy.zeros_like(h_a)
d_a=cuda.memalloc(h_a.nbytes)
d_b=cuda.memalloc(h_b.nbytes)
d_c=cuda.memalloc(h_c.nbytes)
cuda.memcpy_htod(d_a,h_a)
cuda.memcpy_htod(d_b,h_b)
adder(d_a,d_b,d_c,block=(64,64,1),grid=(1,1))
cuda.memcpy_dtoh(h_c,d_c)
print h_c

enter image description here

enter image description here

0 个答案:

没有答案