all CUDA devices are busy or unavailable. Weird version

Hi all.

System spec:
GeForce GTX460 2Gb
Windows 7 x64
Driver version: 280.26, 275.73

I’m getting very weired behavior from CUDA. Not sure if someone else can help me here with that. To understand a problem - here is some background describing what I’m working on.

I have developed the CUDA based volume rendering library for medical imaging. Library is implemented with native C++, uses CUDA and OpenGL interop.
Also there is a ClearCanvas medical application, which is plugin-based. We embed our volume rendering library to this application as a plugin. The ClearCanvas is a .NET application.

Here is some things that work perfectly.

  1. I have the native C++ test project, that links with the VolumeRendering library. I use this project to test all stuff inside VOlumeRendering library.
  2. The ClearCanvas volume rendering plugin. Writed on managed C++. Provides:
    a) a layer between native C++ VolumeRendering library and managed ClearCanvas code
    b) implemented the UI control for displaying volume rendering in ClearCanvas.
    c) There is a code that instantiates this control. And this control is working.
    So everything is work find until here. Now I create
  3. Another ClearCanvas plugin, written on C#. What this plugin does, is just instantiates the same control as in #2-b item. But that doesn’t work (details later).
    When the VOlumeRendering control is created first time - VolumeRendering library is initialized (that means CUDA is initialized). So, initialization path from #2-c and #3 are absolutly the same. The CUDA calls are made in the same order, and at the same thread.

The difference, is #2-c is working, and #3 get “All CUDA capable devices are busy or unavailable” at first call to non-devices management CUDA function!
In my tests, I dont call the #3 after #2-c. I just test either one path, or another. So there can’t be a problem of the fact that something bad is done in #2-c that breaks #3. So #3 just don’t work.

I know that “All CUDA capable devices are busy or unavailable” should come when someone else uses the device in exclusive mode. But this is not the case. Just when #3 returns error, I pause the process (without terminating), and run the #1. #1 executes exactly the same CUDA initialization code, the same binary. And it works!

Well, all that sounds complicated… And actually I don’t expect much of a help in such complex situation. But here is my main question.

What are other possible reasons of getting “All CUDA capable devices are busy or unavailable”?

P.S. Tried different drivers.

Some new info: Disabling OpenGL interop (remove cudaGLSetGLDevice) make it work. But I require the OpenGL interop, so this is not a solution.

Regards, Ivan.

Found a solution.

In path #2-c the OpenGL context was created and activated before the cudaGLSetGLDevice.
In path #3 there were no active OpenGL context when cudaGLSetGLDevice is called.