0

我正在尝试从另一个内核调用 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,所以它应该是兼容的。我错过了什么?

编辑

添加后"options=['--cubin','-rdc=true','-lcudart','-lcudadevrt,','-Ic:\python33\lib\site-packages\pycuda\cuda kernel.cu' ]" 到 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 - 
4

1 回答 1

5

Python 正在动态编译 CUDA 代码:

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

为了编译包含动态并行性的代码,需要在编译命令中添加特定的开关,以启用单独编译、设备代码链接、设备运行时库的链接以及适当的架构目标 ( sm_35)。

有效nvcc命令组合的一些示例在动态并行的编程指南部分中给出。

您的命令行应类似于:

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

您可能还希望阅读有关单独编译的 nvcc 手册。

于 2013-10-14T19:24:00.273 回答