拥有GTX Titan,遇到动态并行问题

时间:2013-10-14 18:58:51

标签: cuda nvcc pycuda

我试图从另一个内核调用CUDA内核,但是得到以下错误:

Traceback (most recent call last):
  File "C:\temp\GPU Program Shell.py", line 22, in <module>
    """)
  File "C:\Python33\lib\site-packages\pycuda\compiler.py", line 262, in __init__
    arch, code, cache_dir, include_dirs)
  File "C:\Python33\lib\site-packages\pycuda\compiler.py", line 252, in compile
    return compile_plain(source, options, keep, nvcc, cache_dir)
  File "C:\Python33\lib\site-packages\pycuda\compiler.py", line 134, in compile_plain
    cmdline, stdout=stdout.decode("utf-8"), stderr=stderr.decode("utf-8"))
pycuda.driver.CompileError: nvcc compilation of         c:\users\karste~1\appdata\local\temp\tmpgq8t45\kernel.cu failed
[command: nvcc --cubin -arch sm_35 -m64 -Ic:\python33\lib\site-packages\pycuda\cuda kernel.cu]
[stderr:
kernel.cu(14): error: kernel launch from __device__ or __global__ functions requires separate         compilation mode

我的理解是,这与动态并行性有关,而与此错误相关的其他问题是由于用户没有适当的硬件。我有一个GTX Titan,所以它应该是兼容的。我错过了什么?

修改

添加&#34;选项= [&#39; - cubin&#39;,&#39; -rdc = true&#39; ,&#39; -lcudart&#39;,&#39; -lcudadevrt,&#39;,&#39; -Ic:\ python33 \ lib \ site-packages \ pycuda \ cuda kernel.cu&#39;]& #34;到SourceModule,我收到以下错误:

Traceback (most recent call last):
  File "C:\temp\GPU Program Shell.py", line 22, in <module>
""", options=['--cubin','-rdc=true' ,'-lcudart', '-lcudadevrt,','-Ic:\python33\lib\site-packages\pycuda\cuda kernel.cu'])
  File "C:\Python33\lib\site-packages\pycuda\compiler.py", line 265, in __init__
self.module = module_from_buffer(cubin)
pycuda._driver.LogicError: cuModuleLoadDataEx failed: not found - 

1 个答案:

答案 0 :(得分:5)

Python正在动态编译CUDA代码:

nvcc --cubin -arch sm_35 -m64 -Ic:\python33\lib\site-packages\pycuda\cuda kernel.cu

为了编译包含动态并行性的代码,有必要在编译命令中添加特定的开关,以启用单独的编译,设备代码链接,设备运行时库的链接以及相应的体系结构目标(sm_35

有效nvcc命令组合的一些示例在programming guide section on dynamic parallelism中给出。

您的命令行应如下所示:

nvcc --cubin -arch=sm_35 -m64 -rdc=true -Ic:\python33\lib\site-packages\pycuda\cuda kernel.cu -lcudadevrt

您可能还希望阅读separate compilation上的nvcc手册。