处理Ctrl + C异常与GPU [英] Handling Ctrl+C exception with GPU

查看:305
本文介绍了处理Ctrl + C异常与GPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些GPU程序(使用CUDA 4.1和C),有时(很少)我必须杀死程序中途使用Ctrl + C来处理一些异常。以前我尝试使用CudaDeviceReset()函数,但是 talonmies的此回复取代了我对CudaDeviceReset()的信任, ),因此我开始处理这种例外的老式方式,即计算机重新启动。随着项目规模的增长,这种方法变得头痛。

I am working with some GPU programs (using CUDA 4.1 and C), and sometimes (rarely) I have to kill the program midway using Ctrl+C to handle some exception. Earlier I tried using CudaDeviceReset() function, but this reply by talonmies displaced my trust in CudaDeviceReset() and hence I started handling such exceptions the Old-Fashioned way, that is 'computer restart'. As the project size grows, this method is becoming a headache. I would appreciate if anyone has come up with a better solution.

推荐答案

我认为这个问题更基础 - 真的应用程序设计问题,而不是CUDA问题。如果你设计你的应用程序正确地检查中断定期,并退出你的主循环和清理资源,中断,然后你不应该有这个问题(甚至可以调用 cudaDeviceReset()正确退出。

I think this question is more fundamental -- it is really an app design issue and not a CUDA issue. If you design your app correctly to check for interrupts regularly, and exit your main loop and clean up resources upon interupt, then you shouldn't have this problem (and you can even call cudaDeviceReset() properly on exit.

这个问题可能会有所帮助。这一个这一个

The answers to this question may be helpful. And this one. And this one.

这篇关于处理Ctrl + C异常与GPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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