i run into a problem with CUDA and OpenGL that kills me for days now. Maybe some of you experience some similar issues. These simple lines generate a PBO in OpenGL and register/unregister the PBO for the use with CUDA.
GLuint pbo; glGenBuffers (1, &pbo); glBindBuffer (GL_PIXEL_UNPACK_BUFFER_ARB, pbo); glBufferData (GL_PIXEL_UNPACK_BUFFER_ARB, size, 0, GL_DYNAMIC_COPY); glBindBuffer (GL_PIXEL_UNPACK_BUFFER_ARB, 0); cudaGraphicsResource* cudaRes = NULL; cudaSetDevice (0); cudaGLSetGLDevice (0); cudaGraphicsGLRegisterBuffer(&cudaRes, pbo, cudaGraphicsMapFlagsWriteDiscard)); cudaGraphicsUnregisterResource(gh_OutputResource);
This compiles and runs fine, but when I try to profile the application using the Nvidia Visual Profiler (distributed with the CUDA 3.1 SDK, running on Windows XP), the cudaGraphicsGLRegisterBuffer call fails with an “Unspecified launch failure”. Usually this signals a segment fault somewhere, but the hell I cant see a segfault here. This drives me crazy, because I really need some profiling for my CUDA kernels. I would really appreciate if you could share some knowledge with me or even reproduce the error in your profiler.
PS. I also noticed, that the error can also be reproduced by using the Visual profiler with the simpleGL example from the SDK. It may not fail the first time, but when multiple times the error occurs also on the “cudaGraphicsGLRegisterBuffer” command in the simpleGL exe.