[Solved] SDK sample5 vs. sample5pp

Hi-

I am using some of the SDK examples on a headless server. I ssh onto a machine with 3 K20s. Those examples that support file output to PPM image seem to work fine.

However, when I compare sample5 and sample5pp (demoing conversion from C to C++), I get different behavior.

./sample5 -f output/test.ppm --> works
./sample5pp -f output/test.ppm --> throws an exception: function _rtContextLaunch2D caught exception CUDA error: cuGLGetDevices() returned (201): Invalid context

Any idea why the C++ version throws this exception? I’d prefer to use the C++ syntax if possible.

I may have figured it out. In sample5, the line
RT_CHECK_ERROR_NO_CONTEXT( sutilInitGlut( &argc, argv ) );
is not executed if a file output is specified.
Whereas, in sample5pp, the line was always being executed. (which is a problem for no-monitor headless setups).

I’m at home right now, so I can’t test, but I suspect this is it.

Yep, this was it. Recommend making this change as a small bug-fix for the next release of the SDK, just so the behavior of the two examples are more similar.