Code work well in Optix 3.9.1 , but fail in Optix 4.0.2

Hello,

I am new to Optix.
My code runs on Optix 3.9.1 successfully.
But when I change environment into Optix 4.0.2, my code isn’t working.

Compiling is alright, but it isn’t running.

When I call ‘m_context->launch( 0, buffer_width, buffer_height );’ first,
Here is the error:
‘OptiX Error: ‘Memory allocation failed (Details: Function “_rtContextLaunch2D” c
aught exception: Encountered a CUDA error: driver().cuLaunchKernel( m_function,
gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, s
tream.get(), kernelParams, extra ) returned (2): Out of memory)’’

So I think my stacksize is too small, i change the stacksize to 128000
with the code ‘m_context->setStackSize( 128000 );’

And I call ‘m_context->launch( 0, buffer_width, buffer_height );’ again,
The error changes:
‘OptiX Error: ‘Invalid value (Details: Function “_rtContextLaunch2D” caught excep
tion: Encountered a CUDA error: driver().cuLaunchKernel( m_function, gridDimX, g
ridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, stream.get()
, kernelParams, extra ) returned (1): Invalid value)’’

So i don’t know what happened. I couldn’t fix these problems.
Could you give me some suggestions? I really want to know how to debug with optix Program easily.
Thanks for your help.

No, it’s quite the opposite. Your stack size is much too big and you’re running out of VRAM on the board just for that.

To find out which stack size is enough do the following:
1.) Add an exception program which prints the exception code and enable it for the whole launch size.
You’ll find links to my code doing that when searching this forum for “rtAssert”, and here: [url]Distance Field Camera Clipping Issue (Julia Demo) - OptiX - NVIDIA Developer Forums
2.) Maybe add a command line variable to your application to set the OptiX stack size. That will make the following iterations quicker.
3.) Shrink the stack size to a small value, like 1024 or even less.
4.) Run the program in a configuration which uses the maximum intended number of recursions and check for stack overflow exceptions. (Start with a small stack size which throws some.)
5.) Increase the stack size until the exceptions in step 4. do not happen anymore.

Use the minimal stack size which doesn’t show stack overflow exceptions anymore and still runs the program.

When reporting OptiX issues please always list the following system information:
OS version, installed GPU(s) (=> how much VRAM?), display driver version, OptiX version, CUDA toolkit version.

Thanks for your help Detlef,

My code is running with setting stack size to 1024.

This is my first time to report OptiX issue, next time I will list my system information.