Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CUDA,cuPrintf原因“;未指定的启动失败“;?_Cuda_Compiler Errors - Fatal编程技术网

CUDA,cuPrintf原因“;未指定的启动失败“;?

CUDA,cuPrintf原因“;未指定的启动失败“;?,cuda,compiler-errors,Cuda,Compiler Errors,我有一个内核,它以不同的网格大小运行两次 我的问题是cuPrintf。当我在内核运行之前没有cudaPrintfInit(),在内核运行之后没有cudaPrintfDisplay(stdout,true)和cudaPrintfEnd()时,我没有错误,但当我把它们放在那里时,我会得到“未指定的启动失败”错误 在我的设备代码中,只有一个这样的打印循环: if (threadIdx.x==0) { cuPrintf("MAX:%f x:%d y:%d\n", maxVal, blockId

我有一个内核,它以不同的网格大小运行两次

我的问题是cuPrintf。当我在内核运行之前没有
cudaPrintfInit()
,在内核运行之后没有
cudaPrintfDisplay(stdout,true)
cudaPrintfEnd()
时,我没有错误,但当我把它们放在那里时,我会得到“未指定的启动失败”错误

在我的设备代码中,只有一个这样的打印循环:

if (threadIdx.x==0) {
     cuPrintf("MAX:%f x:%d y:%d\n", maxVal, blockIdx.x, blockIdx.y);
}
我将CUDA 4.0与具有CUDA功能2.0的卡一起使用,因此我使用以下语法编译代码:

nvcc LB2.0.cu -arch=compute_20 -code=sm_20  

如果您使用的是CC 2.0 GPU,则根本不需要cuPrintf——CUDA为CC-2.0及更高GPU内置了printf。因此,只需将您对cuPrintf的呼叫替换为以下内容:

#if __CUDA_ARCH__ >= 200
if (threadIdx.x==0) {
    printf("MAX:%f x:%d y:%d\n", maxVal, blockIdx.x, blockIdx.y);
}
#endif
(请注意,如果您正在编译sm#U 20和早期版本的代码,则只需要#if/#endif行。使用您提供的示例编译命令行,可以消除它们。)


使用printf,您不需要cudaPrintfInit()或cudaPrintfDisplay()——它是自动的。但是,如果打印大量数据,可能需要通过
cudalimitprintfiffosize
选项增加默认的printf FIFO大小。

如果您使用的是CC 2.0 GPU,则根本不需要cuPrintf——CUDA为CC-2.0及更高GPU内置了printf。因此,只需将您对cuPrintf的呼叫替换为以下内容:

#if __CUDA_ARCH__ >= 200
if (threadIdx.x==0) {
    printf("MAX:%f x:%d y:%d\n", maxVal, blockIdx.x, blockIdx.y);
}
#endif
(请注意,如果您正在编译sm#U 20和早期版本的代码,则只需要#if/#endif行。使用您提供的示例编译命令行,可以消除它们。)

使用printf,您不需要cudaPrintfInit()或cudaPrintfDisplay()——它是自动的。但是,如果打印大量数据,可能需要通过
cudalimitprintfifosize
选项增加默认的printf FIFO大小