I am struggling with an OptiX error that crashes the graphics driver which seems to be related to OptiX variables. Any pointers that can help me understand the error would be most welcome, as right now I just have no idea where to look anymore.
When I run my code, the driver crashes (black screen followed by popup message), and the console shows the following output:
Unknown error <Details: Function "_rtContextLaunch2D" caught exception: Encountered a CUDA error: driver<>.cuMemcpyDtoHAsync< dstHost, srcDevice, byteCount, hStream.get<> > returned <999>: Unknown, file:C:\u\workspace\rel4.0-win64-build-Release\sw\wsapps\raytracing\rtsdk\rel4.0\src\CUDA\Memory.cpp, line: 134>
This error occurs from trying to access a variable inside one of my Closest Hit programs that is set on the host and accessed on the device as follows:
host code:
_context["tx_k"]->setFloat(transmitter._waveNumber);
outside program in .cu file:
rtDeclareVariable(float, tx_k, , );
inside closest hit program in .cu file:
printf("test: %f \n", tx_k); // this line crashes the code - if I comment it out and don't use tx_k elsewhere all is well
This problem also exists when trying to use tx_k in a computation rather than printing it.
Interestingly, the same variable tx_k is also used in another closest hit program (in another .cu file) where it does not give any problems, and I also use other variables in the problem .cu file that are set at the GeometryInstance level that are fine. Changing the host-side definition of tx_k to be 1.0f, or trying to use another Context level variable in this closest hit program gives the same problem.
I’ve tried running the code in debug mode inside visual studio, which has sometimes helped me get more information on errors from OptiX, but in visual studio debug mode the code runs without any problems. I’ve also performed an OAC trace, which doesn’t seem to show anything useful to me, but I’ve appended it below (setting tx_k returns 0 and shows a sensible value, and the error happens on rtContextLaunch2D, which returns -1).
This is on Windows 7 64-bit, Geforce 970, CUDA 7.5, OptiX 4.0. Driver is currently 372.54, but the problem already existed on two previous drivers, as I wasn’t current up to yesterday, when the problem started, so I updated to the previous driver (368.81, I think?) yesterday, and again today when 372.54 came out.
edit: Reverting to OptiX 3.9.0 solves my problem. That doesn’t help me understand what’s going on, but maybe it will help someone on here understand. It also isn’t a very good long term solution, as I’m working on a long-term project, so I want to stay with the latest version.
OAC trace:
10
64
Platform: Windows
CUDA driver version: 8000
OptiX Version:[4.0.0] Build Number:[20966047] CUDA Version:[7.5] 64-bit 2016-07-21
Command line: DeviceUnitTests.exe
Capture time: 2016-08-16 14:20:38+01:00
%%
rtContextCreate( 00000000002CF1D0 )
res = 0
hdl = 000000000013E340
rtGroupCreate( 000000000013E340, 00000000002CF280 )
res = 0
hdl = 0000000002CB6D90
rtAccelerationCreate( 000000000013E340, 00000000002CF280 )
res = 0
hdl = 0000000002BF75E0
rtAccelerationSetBuilder( 0000000002BF75E0, NoAccel )
res = 0
rtBufferCreate( 000000000013E340, 2, 00000000002CF280 )
// BUFFER_OUTPUT
res = 0
hdl = 00000000039A7F90
rtBufferSetFormat( 00000000039A7F90, 285 )
// RT_FORMAT_USER
res = 0
rtBufferSetSize1D( 00000000039A7F90, 1000000 )
res = 0
rtBufferCreate( 000000000013E340, 3, 00000000002CF280 )
// BUFFER_INPUT | BUFFER_OUTPUT
res = 0
hdl = 00000000039A8080
rtBufferSetFormat( 00000000039A8080, 277 )
// RT_FORMAT_INT
res = 0
rtBufferSetSize1D( 00000000039A8080, 1 )
res = 0
rtProgramCreateFromPTXString( 000000000013E340, <str>, raygen, 00000000002CF120 )
file = oac.ptx.000000.potx
res = 0
hdl = 0000000003913BB0
rtProgramCreateFromPTXString( 000000000013E340, <str>, ignore_hit, 00000000002CF120 )
file = oac.ptx.000001.potx
res = 0
hdl = 00000000060B7D60
rtProgramCreateFromPTXString( 000000000013E340, <str>, terminate_on_hit, 00000000002CF120 )
file = oac.ptx.000001.potx
res = 0
hdl = 0000000003A66150
rtProgramCreateFromPTXString( 000000000013E340, <str>, ray_done, 00000000002CF120 )
file = oac.ptx.000001.potx
res = 0
hdl = 0000000003A26730
rtProgramCreateFromPTXString( 000000000013E340, <str>, receiver_hit, 00000000002CF120 )
file = oac.ptx.000002.potx
res = 0
hdl = 0000000003ABF190
rtProgramCreateFromPTXString( 000000000013E340, <str>, material_hit, 00000000002CF120 )
file = oac.ptx.000003.potx
res = 0
hdl = 0000000006343260
rtProgramCreateFromPTXString( 000000000013E340, <str>, intersect, 00000000002CF120 )
file = oac.ptx.000004.potx
res = 0
hdl = 0000000003A600B0
rtProgramCreateFromPTXString( 000000000013E340, <str>, bounds, 00000000002CF120 )
file = oac.ptx.000004.potx
res = 0
hdl = 0000000006481FE0
rtProgramCreateFromPTXString( 000000000013E340, <str>, exception, 00000000002CF120 )
file = oac.ptx.000005.potx
res = 0
hdl = 0000000006481C60
rtContextSetRayTypeCount( 000000000013E340, 2 )
res = 0
rtContextSetEntryPointCount( 000000000013E340, 1 )
res = 0
rtContextSetRayGenerationProgram( 000000000013E340, 0, 0000000003913BB0 )
res = 0
rtContextQueryVariable( 000000000013E340, minIntersectionDistance, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, minIntersectionDistance, 00000000002CF1D0 )
res = 0
hdl = 0000000006145110
rtVariableSet1f( 0000000006145110, 0.001 )
res = 0
rtContextQueryVariable( 000000000013E340, overlapFactor, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, overlapFactor, 00000000002CF1D0 )
res = 0
hdl = 0000000006144CD0
rtVariableSet1f( 0000000006144CD0, 1.03 )
res = 0
rtContextQueryVariable( 000000000013E340, maxLinearConeSize, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, maxLinearConeSize, 00000000002CF1D0 )
res = 0
hdl = 0000000006145220
rtVariableSet1f( 0000000006145220, 1 )
res = 0
rtContextQueryVariable( 000000000013E340, maxCurvatureOverCone, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, maxCurvatureOverCone, 00000000002CF1D0 )
res = 0
hdl = 0000000006145330
rtVariableSet1f( 0000000006145330, 0.174533 )
res = 0
rtContextSetMissProgram( 000000000013E340, 0, 0000000003A26730 )
res = 0
rtGroupSetChildCount( 0000000002CB6D90, 0 )
res = 0
rtGroupSetAcceleration( 0000000002CB6D90, 0000000002BF75E0 )
res = 0
rtContextQueryVariable( 000000000013E340, top_object, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, top_object, 00000000002CF1D0 )
res = 0
hdl = 0000000006145440
rtVariableSetObject( 0000000006145440, 0000000002CB6D90 )
res = 0
rtContextSetExceptionEnabled( 000000000013E340, 2147483647, 1 )
res = 0
rtContextSetExceptionProgram( 000000000013E340, 0, 0000000006481C60 )
res = 0
rtContextSetStackSize( 000000000013E340, 2048 )
res = 0
rtBufferSetElementSize( 00000000039A7F90, 112 )
res = 0
rtContextQueryVariable( 000000000013E340, outputBuffer, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, outputBuffer, 00000000002CF1D0 )
res = 0
hdl = 0000000006145550
rtVariableSetObject( 0000000006145550, 00000000039A7F90 )
res = 0
rtContextQueryVariable( 000000000013E340, numberRaysReceivedBuffer, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, numberRaysReceivedBuffer, 00000000002CF1D0 )
res = 0
hdl = 0000000006145660
rtVariableSetObject( 0000000006145660, 00000000039A8080 )
res = 0
rtBufferCreate( 000000000013E340, 2, 00000000002CF280 )
// BUFFER_OUTPUT
res = 0
hdl = 00000000039A8170
rtBufferSetFormat( 00000000039A8170, 260 )
// RT_FORMAT_FLOAT4
res = 0
rtBufferSetSize2D( 00000000039A8170, 1000, 1000 )
res = 0
rtContextQueryVariable( 000000000013E340, tilingBuffer, 00000000002CF1D0 )
res = 0
rtContextDeclareVariable( 000000000013E340, tilingBuffer, 00000000002CF1D0 )
res = 0
hdl = 0000000006145770
rtVariableSetObject( 0000000006145770, 00000000039A8170 )
res = 0
rtMaterialCreate( 000000000013E340, 00000000002CF2B0 )
res = 0
hdl = 00000000061CEC70
rtMaterialSetClosestHitProgram( 00000000061CEC70, 1, 0000000003ABF190 )
res = 0
rtMaterialSetAnyHitProgram( 00000000061CEC70, 0, 00000000060B7D60 )
res = 0
rtContextSetDevices( 000000000013E340, 1, 0000000006B17DB0 )
val = 0
res = 0
rtMaterialCreate( 000000000013E340, 00000000002CF2F0 )
res = 0
hdl = 00000000061CEF30
rtMaterialSetClosestHitProgram( 00000000061CEF30, 0, 0000000006343260 )
res = 0
rtMaterialSetAnyHitProgram( 00000000061CEF30, 1, 0000000003A66150 )
res = 0
rtMaterialQueryVariable( 00000000061CEF30, materialType, 00000000002CF240 )
res = 0
rtMaterialDeclareVariable( 00000000061CEF30, materialType, 00000000002CF240 )
res = 0
hdl = 0000000006145880
rtVariableSet1ui( 0000000006145880, 0 )
res = 0
rtGeometryGroupCreate( 000000000013E340, 00000000002CEE90 )
res = 0
hdl = 0000000006B4E430
rtGeometryGroupSetChildCount( 0000000006B4E430, 0 )
res = 0
rtAccelerationCreate( 000000000013E340, 00000000002CEE90 )
res = 0
hdl = 0000000006480C60
rtAccelerationSetBuilder( 0000000006480C60, Bvh )
res = 0
rtGeometryGroupSetAcceleration( 0000000006B4E430, 0000000006480C60 )
res = 0
rtGroupGetChildCount( 0000000002CB6D90, 00000000002CEE90 )
res = 0
rtGroupSetChildCount( 0000000002CB6D90, 1 )
res = 0
rtGroupSetChild( 0000000002CB6D90, 0, 0000000006B4E430 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CEC70 )
// BUFFER_INPUT
res = 0
hdl = 00000000039A8530
rtBufferSetFormat( 00000000039A8530, 260 )
// RT_FORMAT_FLOAT4
res = 0
rtBufferSetSize2D( 00000000039A8530, 1000, 1000 )
res = 0
rtBufferMapEx( 00000000039A8530, 2, 0, 0000000000000000, 00000000002CECF8 )
res = 0
rtBufferUnmapEx( 00000000039A8530, 0 )
file = oac.buf.000005.potx
res = 0
rtGeometryCreate( 000000000013E340, 00000000002CE9E0 )
res = 0
hdl = 000000000631EC10
rtGeometrySetPrimitiveCount( 000000000631EC10, 2 )
res = 0
rtGeometrySetBoundingBoxProgram( 000000000631EC10, 0000000006481FE0 )
res = 0
rtGeometrySetIntersectionProgram( 000000000631EC10, 0000000003A600B0 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CE9E0 )
// BUFFER_INPUT
res = 0
hdl = 00000000039A8620
rtBufferSetFormat( 00000000039A8620, 285 )
// RT_FORMAT_USER
res = 0
rtBufferSetSize1D( 00000000039A8620, 2 )
res = 0
rtBufferSetElementSize( 00000000039A8620, 112 )
res = 0
rtGeometryQueryVariable( 000000000631EC10, tri, 00000000002CE930 )
res = 0
rtGeometryDeclareVariable( 000000000631EC10, tri, 00000000002CE930 )
res = 0
hdl = 0000000006145990
rtVariableSetObject( 0000000006145990, 00000000039A8620 )
res = 0
rtBufferMapEx( 00000000039A8620, 2, 0, 0000000000000000, 00000000002CEA18 )
res = 0
rtBufferUnmapEx( 00000000039A8620, 0 )
file = oac.buf.000006.potx
res = 0
rtGeometryInstanceCreate( 000000000013E340, 00000000002CECF0 )
res = 0
hdl = 00000000065CCE90
rtGeometryInstanceSetGeometry( 00000000065CCE90, 000000000631EC10 )
res = 0
rtGeometryInstanceSetMaterialCount( 00000000065CCE90, 1 )
res = 0
rtGeometryInstanceSetMaterial( 00000000065CCE90, 0, 00000000061CEC70 )
res = 0
rtGeometryInstanceQueryVariable( 00000000065CCE90, receiverNormal, 00000000002CEC40 )
res = 0
rtGeometryInstanceDeclareVariable( 00000000065CCE90, receiverNormal, 00000000002CEC40 )
res = 0
hdl = 0000000006145AA0
rtVariableSet3fv( 0000000006145AA0, 00000000002CEDF0 )
val = -1 0 0
res = 0
rtGeometryInstanceQueryVariable( 00000000065CCE90, receiverPolarization, 00000000002CEC40 )
res = 0
rtGeometryInstanceDeclareVariable( 00000000065CCE90, receiverPolarization, 00000000002CEC40 )
res = 0
hdl = 0000000006145BB0
rtVariableSet3fv( 0000000006145BB0, 00000000002CEDE0 )
val = 0 0 -1
res = 0
rtGeometryInstanceQueryVariable( 00000000065CCE90, instanceID, 00000000002CEC40 )
res = 0
rtGeometryInstanceDeclareVariable( 00000000065CCE90, instanceID, 00000000002CEC40 )
res = 0
hdl = 0000000006145CC0
rtVariableSet1i( 0000000006145CC0, 1 )
res = 0
rtGeometryInstanceQueryVariable( 00000000065CCE90, velocity, 00000000002CEEA0 )
res = 0
rtGeometryInstanceDeclareVariable( 00000000065CCE90, velocity, 00000000002CEEA0 )
res = 0
hdl = 0000000006145DD0
rtVariableSet3fv( 0000000006145DD0, 00000000002CEFA0 )
val = 0 0 0
res = 0
rtGeometryGroupGetChildCount( 0000000006B4E430, 00000000002CEF50 )
res = 0
rtGeometryGroupSetChildCount( 0000000006B4E430, 1 )
res = 0
rtGeometryGroupSetChild( 0000000006B4E430, 0, 00000000065CCE90 )
res = 0
rtGeometryCreate( 000000000013E340, 00000000002CE6F0 )
res = 0
hdl = 0000000006DF9170
rtGeometrySetPrimitiveCount( 0000000006DF9170, 5120 )
res = 0
rtGeometrySetBoundingBoxProgram( 0000000006DF9170, 0000000006481FE0 )
res = 0
rtGeometrySetIntersectionProgram( 0000000006DF9170, 0000000003A600B0 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CE6F0 )
// BUFFER_INPUT
res = 0
hdl = 00000000039A8800
rtBufferSetFormat( 00000000039A8800, 285 )
// RT_FORMAT_USER
res = 0
rtBufferSetSize1D( 00000000039A8800, 5120 )
res = 0
rtBufferSetElementSize( 00000000039A8800, 112 )
res = 0
rtGeometryQueryVariable( 0000000006DF9170, tri, 00000000002CE640 )
res = 0
rtGeometryDeclareVariable( 0000000006DF9170, tri, 00000000002CE640 )
res = 0
hdl = 0000000006145EE0
rtVariableSetObject( 0000000006145EE0, 00000000039A8800 )
res = 0
rtBufferMapEx( 00000000039A8800, 2, 0, 0000000000000000, 00000000002CE728 )
res = 0
rtBufferUnmapEx( 00000000039A8800, 0 )
file = oac.buf.000007.potx
res = 0
rtGeometryGetPrimitiveCount( 0000000006DF9170, 00000000002CEE80 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CEE20 )
// BUFFER_INPUT
res = 0
hdl = 00000000039A88F0
rtBufferSetFormat( 00000000039A88F0, 285 )
// RT_FORMAT_USER
res = 0
rtBufferSetSize1D( 00000000039A88F0, 5120 )
res = 0
rtBufferSetElementSize( 00000000039A88F0, 112 )
res = 0
rtBufferMapEx( 00000000039A8800, 2, 0, 0000000000000000, 00000000002CEE90 )
res = 0
rtBufferMapEx( 00000000039A88F0, 2, 0, 0000000000000000, 00000000002CEEC8 )
res = 0
rtBufferUnmapEx( 00000000039A88F0, 0 )
file = oac.buf.000008.potx
res = 0
rtBufferUnmapEx( 00000000039A8800, 0 )
file = oac.buf.000009.potx
res = 0
rtGeometryCreate( 000000000013E340, 00000000002CEE20 )
res = 0
hdl = 0000000006DF92E0
rtGeometrySetPrimitiveCount( 0000000006DF92E0, 5120 )
res = 0
rtGeometrySetBoundingBoxProgram( 0000000006DF92E0, 0000000006481FE0 )
res = 0
rtGeometrySetIntersectionProgram( 0000000006DF92E0, 0000000003A600B0 )
res = 0
rtGeometryQueryVariable( 0000000006DF92E0, tri, 00000000002CED70 )
res = 0
rtGeometryDeclareVariable( 0000000006DF92E0, tri, 00000000002CED70 )
res = 0
hdl = 0000000006145FF0
rtVariableSetObject( 0000000006145FF0, 00000000039A88F0 )
res = 0
rtGeometryInstanceCreate( 000000000013E340, 00000000002CF000 )
res = 0
hdl = 0000000006DF9450
rtGeometryInstanceSetGeometry( 0000000006DF9450, 0000000006DF92E0 )
res = 0
rtGeometryInstanceSetMaterialCount( 0000000006DF9450, 1 )
res = 0
rtGeometryInstanceSetMaterial( 0000000006DF9450, 0, 00000000061CEF30 )
res = 0
rtGeometryInstanceQueryVariable( 0000000006DF9450, instanceID, 00000000002CEF50 )
res = 0
rtGeometryInstanceDeclareVariable( 0000000006DF9450, instanceID, 00000000002CEF50 )
res = 0
hdl = 0000000006146100
rtVariableSet1i( 0000000006146100, 1 )
res = 0
rtGeometryInstanceQueryVariable( 0000000006DF9450, velocity, 00000000002CEF50 )
res = 0
rtGeometryInstanceDeclareVariable( 0000000006DF9450, velocity, 00000000002CEF50 )
res = 0
hdl = 0000000003A145A0
rtVariableSet3fv( 0000000003A145A0, 00000000002CF060 )
val = 0 0 0
res = 0
rtGeometryGroupGetChildCount( 0000000006B4E430, 00000000002CF000 )
res = 0
rtGeometryGroupSetChildCount( 0000000006B4E430, 2 )
res = 0
rtGeometryGroupSetChild( 0000000006B4E430, 1, 0000000006DF9450 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CF170 )
// BUFFER_INPUT
res = 0
hdl = 00000000061291F0
rtBufferSetFormat( 00000000061291F0, 259 )
// RT_FORMAT_FLOAT3
res = 0
rtBufferSetSize1D( 00000000061291F0, 1 )
res = 0
rtContextQueryVariable( 000000000013E340, receiverWorldPositions, 00000000002CF0C0 )
res = 0
rtContextDeclareVariable( 000000000013E340, receiverWorldPositions, 00000000002CF0C0 )
res = 0
hdl = 0000000006DF8170
rtVariableSetObject( 0000000006DF8170, 00000000061291F0 )
res = 0
rtContextQueryVariable( 000000000013E340, nReceivers, 00000000002CF0C0 )
res = 0
rtContextDeclareVariable( 000000000013E340, nReceivers, 00000000002CF0C0 )
res = 0
hdl = 0000000006DF8280
rtVariableSet1i( 0000000006DF8280, 1 )
res = 0
rtBufferCreate( 000000000013E340, 1, 00000000002CF170 )
// BUFFER_INPUT
res = 0
hdl = 00000000061292E0
rtBufferSetFormat( 00000000061292E0, 260 )
// RT_FORMAT_FLOAT4
res = 0
rtBufferSetSize2D( 00000000061292E0, 0, 0 )
res = 0
rtContextQueryVariable( 000000000013E340, directionMap, 00000000002CF0C0 )
res = 0
rtContextDeclareVariable( 000000000013E340, directionMap, 00000000002CF0C0 )
res = 0
hdl = 0000000006DF8390
rtVariableSetObject( 0000000006DF8390, 00000000061292E0 )
res = 0
rtContextValidate( 000000000013E340 )
res = 0
rtContextCompile( 000000000013E340 )
res = 0
rtBufferMapEx( 00000000039A8080, 2, 0, 0000000000000000, 00000000002CF100 )
res = 0
rtBufferUnmapEx( 00000000039A8080, 0 )
file = oac.buf.000010.potx
res = 0
rtBufferMapEx( 00000000061291F0, 2, 0, 0000000000000000, 00000000002CF150 )
res = 0
rtBufferUnmapEx( 00000000061291F0, 0 )
file = oac.buf.000011.potx
res = 0
rtContextQueryVariable( 000000000013E340, tx_k, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, tx_k, 00000000002CF050 )
res = 0
hdl = 0000000006DF84A0
rtVariableSet1f( 0000000006DF84A0, 62.8319 )
res = 0
rtContextQueryVariable( 000000000013E340, tx_pos, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, tx_pos, 00000000002CF050 )
res = 0
hdl = 0000000006DF85B0
rtVariableSet3fv( 0000000006DF85B0, 00000000002CF1E0 )
val = 200 0 0
res = 0
rtContextQueryVariable( 000000000013E340, tx_normal, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, tx_normal, 00000000002CF050 )
res = 0
hdl = 0000000006DF86C0
rtVariableSet3fv( 0000000006DF86C0, 00000000002CF1B0 )
val = -1 0 0
res = 0
rtContextQueryVariable( 000000000013E340, tx_pol, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, tx_pol, 00000000002CF050 )
res = 0
hdl = 0000000006DF87D0
rtVariableSet3fv( 0000000006DF87D0, 00000000002CF1C0 )
val = 0 0 -1
res = 0
rtContextQueryVariable( 000000000013E340, transmitterVelocity, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, transmitterVelocity, 00000000002CF050 )
res = 0
hdl = 0000000006DF88E0
rtVariableSet3fv( 0000000006DF88E0, 00000000002CF160 )
val = 0 0 0
res = 0
rtContextQueryVariable( 000000000013E340, transmitterID, 00000000002CF050 )
res = 0
rtContextDeclareVariable( 000000000013E340, transmitterID, 00000000002CF050 )
res = 0
hdl = 0000000006DF89F0
rtVariableSet1i( 0000000006DF89F0, 1 )
res = 0
rtContextQueryVariable( 000000000013E340, directionMap, 00000000002CF050 )
res = 0
rtVariableSetObject( 0000000006DF8390, 00000000039A8530 )
res = 0
rtContextLaunch2D( 000000000013E340, 0, 1000, 1000 )
res = -1