【问题标题】:compilation .cu files with Dynamic Parallelism(CUDA)使用动态并行(CUDA)编译 .cu 文件
【发布时间】:2015-03-07 06:10:34
【问题描述】:

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

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.

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

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

谢谢

【问题讨论】:

  • 关于不受支持的体系结构消息,有一个为 CUDA 6.5 提供的更新以支持 cc5.2。它是here。如果您安装它,该特定错误应该会消失。
  • 谢谢,已经下载。第一个问题怎么样?我必须以某种方式包含选项 -rdc=true 是真的吗?
  • 是的,您必须启用单独的编译和链接,并且您还需要包含一些额外的库。也许您应该查看 cuda 示例中的 VS 项目文件之一,例如 the device cublas sample

标签: cuda dynamic-parallelism


【解决方案1】:

关于第 1 项,cuda 动态并行性需要 separate compilation and linking (-rdc=true),以及设备 cudart 库 (-lcudadevrt) 的链接。也使用 CUBLAS 的动态并行性也需要在设备 CUBLAS 库 (-lcublas_device) 中进行链接。定义所有这些在 Visual Studio 项目中的位置的最简单方法可能是从查看 the device cublas sample 的 Visual Studio 项目开始。

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

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

【讨论】:

    猜你喜欢
    • 2018-12-08
    • 2023-03-23
    • 2014-01-31
    • 1970-01-01
    • 2021-12-19
    • 2020-02-05
    • 2018-09-13
    • 2018-02-17
    • 2018-02-02
    相关资源
    最近更新 更多