Reputation: 667
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."
Actually, even though I use cudaDeviceProp and cudaChooseDevice before calling cudaGLSetDevice, the error still exists.
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.
And I use the Windows SDK to render OpenGL instead of glut, is problem about this?
Upvotes: 0
Views: 1898
Reputation: 1839
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.
Upvotes: 2