Exception is thrown when compiling scene under Windows 64-bit


I get the following exceptions when trying to run my code using Windows 64-bit with Optix 3.0.0
OptiX Error: Unknow error (Details: Function “_rtContextCompile” caught exception: Encountered a CUDA error: cudaFree(0) returned (46) Unknown, [3735657])

Under Linux 64-bit OptiX 3.0.0 the error does not appear.
Using Windows 64-bit Optix 2.5.1 the error did not appear as well.

I tested it with the CUDA Toolkit 4.2.9 and 5.0 and the current device driver included with CUDA 5.0

Right now it is hard for me to separate the problem in a small example project.

Thanks for any hints.

I just looked up the error code (46) from the cuda runtime, and this is the text:

     * This indicates that all CUDA devices are busy or unavailable at the current
     * time. Devices are often busy/unavailable due to use of
     * ::cudaComputeModeExclusive, ::cudaComputeModeProhibited or when long
     * running CUDA kernels have filled up the GPU and are blocking new work
     * from starting. They can also be unavailable due to memory constraints
     * on a device that already has active CUDA work being performed.
    cudaErrorDevicesUnavailable           =     46,

In OptiX 3.0 we now use the CUDA runtime to create CUDA contexts, so that we can share data between other CUDA applications and OptiX. The call to cudaFree(0) is the generally accepted way to initialize the CUDA run time context. For whatever reason CUDA is returning this error.

Do the precompiled samples from the SDK work? If so then there might be some unforeseen interaction with your application.

Thanks for the good hints, with them I was able to find the error.
I used the following functions to set my CUDA device.
By disabeling them the error disappeared.
I don’t understand it completely because first I used to set my Cuda device for OptiX and then I set my Cuda device for CUDA kernels.
So in my opinion the CUDA kernels should not find a valid device and not the OptiX library.
But anyhow because of the new interoperability functions between cuda and optix I need to change this anyway.
Maybe there should be a hint in the documentation that setting the cuda device manual for cuda kernels can cause problems.

Is it just the cudaGLSetGLDevice or was it both of the functions? OptiX should allow you to do this.

It is just the cudaGLSetGLDevice function.
The cudaSetDevice function is causing no problems.

Did you create an openGL context first? It is needed in order to call cudaGLSetGLDevice for a specific device

Good point.
I’m using glutInit but this is not creating a context as far as I know.
The context is created after the cudaGLSetGLDevice.
Thanks for the hint.