为什么cudaGLSetGLDevice失败,即使它在main函数的第一行中调用 [英] Why cudaGLSetGLDevice failed, even though it's called in the first line of main function

查看:1180
本文介绍了为什么cudaGLSetGLDevice失败,即使它在main函数的第一行中调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用OpenGL和CUDA之间的互操作性。我知道,正如一些教程说的,第一步是选择设备。但是,当我在主函数的第一行调用cudaGLSetGLDevice(0)时,程序退出时带有信息cudaSafeCall()Runtime API错误36:在此过程中设备处于活动状态时无法设置。

I want to use interoperability between OpenGL and CUDA. I know, as some tutorials said, the first step is to choose device. However, when I called the cudaGLSetGLDevice(0) in the first line of the main function, the program exited with the information "cudaSafeCall() Runtime API error 36: cannot set while device is active in this process."

实际上,即使我在调用cudaGLSetDevice之前使用cudaDeviceProp和cudaChooseDevice,错误仍然存​​在。

Actually, even though I use cudaDeviceProp and cudaChooseDevice before calling cudaGLSetDevice, the error still exists.

相信我,我的电脑只有一个GPU,9800GT。我知道,cudaGLSetGLDevice的调用应该在任何其他CUDA函数之前,这就是为什么我把它放在main函数的第一行。

Believe me, my computer just has one GPU, 9800GT. And I do know that the calling of cudaGLSetGLDevice should be prior to any other CUDA function so that's why I put it in the first line of main function.

我使用Windows SDK来渲染OpenGL而不是glut,这是有问题的吗?

And I use the Windows SDK to render OpenGL instead of glut, is problem about this?

推荐答案

您需要在调用 cudaGLSetDevice 之前初始化opengl上下文。在glut glutInit(argc,argv); 被调用的情况下。在使用任何cuda< - opengl互操作性函数调用之前初始化opengl上下文。

You need in opengl context initialized before call cudaGLSetDevice. In case of glut glutInit(argc, argv); is called. Initialize opengl context before use any cuda<->opengl interoperability functions call.

这篇关于为什么cudaGLSetGLDevice失败,即使它在main函数的第一行中调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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