CUDA,cuPrintf导致“未指定的启动失败”? [英] CUDA, cuPrintf causes "unspecified launch failure"?

查看:389
本文介绍了CUDA,cuPrintf导致“未指定的启动失败”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a kernel which runs twice with different grid size.

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

My problem is with cuPrintf. When I don't have cudaPrintfInit() before kernel run and cudaPrintfDisplay(stdout, true) and cudaPrintfEnd() after kernel run, I have no error but when I put them there I get "unspecified launch failure" error.

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

In my device code, there is only one loop like this for printing:

if (threadIdx.x==0) {
     cuPrintf("MAX:%f x:%d y:%d\n", maxVal, blockIdx.x, blockIdx.y);
}

我使用CUDA 4.0和cuda功能2.0的卡,所以我使用以下语法编译我的代码:

I'm using CUDA 4.0 with a card with cuda capability 2.0 and so I'm compiling my code with this syntax:

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


推荐答案

如果您使用的是CC 2.0 GPU, cuPrintf - CUDA有内置于CC-2.0和更高版本GPU的printf。因此,只需用以下代码替换你的调用cuPrintf:

If you are on a CC 2.0 GPU, you don't need cuPrintf at all -- CUDA has printf built-in for CC-2.0 and higher GPUs. So just replace your call to cuPrintf with this:

#if __CUDA_ARCH__ >= 200
if (threadIdx.x==0) {
    printf("MAX:%f x:%d y:%d\n", maxVal, blockIdx.x, blockIdx.y);
}
#endif

(注意你只需要#if / endif lines如果你正在编译sm_20和早期版本的代码)。

(Note you only need the #if / #endif lines if you are compiling your code for sm_20 and also earlier versions. With the example compilation command line you gave, you can eliminate them.)

使用printf,你可以不需要cudaPrintfInit()或cudaPrintfDisplay() - 它是自动的。但是,如果您打印了大量数据,则可能需要使用 cudaDeviceSetLimit(),传递 cudaLimitPrintfFifoSize 选项。

With printf, you don't need cudaPrintfInit() or cudaPrintfDisplay() -- it is automatic. However if you print a lot of data, you may need to increase the default printf FIFO size with cudaDeviceSetLimit(), passing the cudaLimitPrintfFifoSize option.

这篇关于CUDA,cuPrintf导致“未指定的启动失败”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆