使用动态并行 (CUDA) 编译 .cu 文件

Mik*_*kin 7 cuda dynamic-parallelism

我换了一个新的 GPU GeForce GTX 980 cc 5.2,所以它必须支持动态并行。但是,我什至无法编译一个简单的代码(来自编程指南)。我不会在这里提供它(没有必要,只是有一个全局内核调用另一个全局内核)。

1)我使用VS2013进行编码。在 中property pages -> CUDA C/C++ -> device,我将code generation属性更改为compute_35,sm_35,这是输出:

1>------ Build started: Project: testCublas3, Configuration: Debug Win32 ------
1>  Compiling CUDA source file kernel.cu...
1>  
1>  C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3>"C:\Program      Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include"  -G   --keep-dir Debug -maxrregcount=0  --machine 32 --compile -cudart static  -g   -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd  " -o Debug\kernel.cu.obj "C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3\kernel.cu" 
1>C:/programs/misha/cuda/Projects/test projects/testCublas3/testCublas3/kernel.cu(13): error : kernel launch from __device__ or __global__ functions requires separate compilation mode
1>  kernel.cu
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets(593,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include"  -G   --keep-dir Debug -maxrregcount=0  --machine 32 --compile -cudart static  -g   -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd  " -o Debug\kernel.cu.obj "C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3\kernel.cu"" exited with code 2.
Run Code Online (Sandbox Code Playgroud)

我想,这个编译我需要另一个选项:-rdc=true,但我没有找到可以在 VS2013 中设置它的位置。

2)当我将code generation属性设置为 时compute_52,sm_52,出现错误:Unsupported gpu architecture 'compute_52'。但是我的cc是5.2。所以我最多可以编译 3.5 cc 的代码?

谢谢

Rob*_*lla 6

关于第1条,cuda动态并行需要单独编译和链接-rdc=true),以及设备cudart库的链接(-lcudadevrt)。也使用 CUBLAS 的动态并行性也需要在设备 CUBLAS 库 ( -lcublas_device) 中进行链接。可能最简单的方法来定义所有这些应该在 Visual Studio 项目中的位置是从查看设备 cublas 示例的 Visual Studio 项目开始。

关于第 2 项,您的 GTX 980 计算能力 5.2 未被识别的原因是您需要 cuda 6.5 工具包的最新更新,可在此处获得

(请注意,该cublas_device功能已从最新版本的 CUDA 中删除。)