使用CUDA时出错无效值

时间:2014-12-29 22:10:49

标签: python cuda anaconda spyder numba-pro

我正在尝试运行我找到here的示例程序:

import numpy as np
from timeit import default_timer as timer
from numbapro import vectorize

@vectorize(["float32(float32, float32)"], target='gpu')
def VectorAdd(a, b):
    return a + b

def main():
    N = 32000000 # Number of elements per array

    A = np.ones(N, dtype=np.float32)
    B = np.ones(N, dtype=np.float32)
    C = np.zeros(N, dtype=np.float32)

    start = timer()
    C = VectorAdd(A,B)
    vectoradd_time = timer() - start

    print("C[:5] = "+str(C[:5]))
    print("C[-5:] = "+str(C[-5:]))

    print("VectorAdd took %f seconds" % vectoradd_time)


if __name__ == '__main__':
    main()

但是我收到以下回溯错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Charlie\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "C:/Users/Charlie/Desktop/development/gcc_vs_pythonGPU/GPU_python.py", line 27, in <module>
    main()
  File "C:/Users/Charlie/Desktop/development/gcc_vs_pythonGPU/GPU_python.py", line 17, in main
    C = VectorAdd(A,B)
  File "C:\aroot\stage\Lib\site-packages\numbapro\cudavec\dispatch.py", line 36, in __call__
  File "C:\aroot\stage\Lib\site-packages\numbapro\common\deviceufunc.py", line 207, in call
  File "C:\aroot\stage\Lib\site-packages\numbapro\cudavec\dispatch.py", line 207, in launch
  File "C:\aroot\stage\Lib\site-packages\numbapro\cudapy\plugins.py", line 95, in __call__
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\compiler.py", line 228, in __call__
    sharedmem=self.sharedmem)
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\compiler.py", line 268, in _kernel_call
    cu_func(*args)
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\cudadrv\driver.py", line 1044, in __call__
    self.sharedmem, streamhandle, args)
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\cudadrv\driver.py", line 1088, in launch_kernel
    None)
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\cudadrv\driver.py", line 215, in safe_cuda_api_call
    self._check_error(fname, retcode)
  File "C:\Users\Charlie\Anaconda\lib\site-packages\numba\cuda\cudadrv\driver.py", line 245, in _check_error
    raise CudaAPIError(retcode, msg)
numba.cuda.cudadrv.driver.CudaAPIError: Call to cuLaunchKernel results in CUDA_ERROR_INVALID_VALUE

关于出了什么问题的任何想法?我尝试在此页面上运行“基本示例”: http://docs.continuum.io/numbapro/CUDAufunc.html 它工作得很好,但第一个是造成问题,我不知道为什么。如果它有任何区别,我没有按照建议安装visual studio,但我认为这不是问题。非常感谢任何帮助..

0 个答案:

没有答案