hello,
I’m writing a Unity(d3d11) progam. It calls a native plugin which uses cuda to do some post processing. The process loop is like this
cudaGraphicsMapResources(1, &inputRes, gPostSR->getCudaStream()); // return cudaErrorUnknown after a few loops
cudaGraphicsSubResourceGetMappedArray(&inArr, inputRes, 0, 0);
cudaMemcpy2DFromArrayAsync(gPostSR->inputBuffer(), iw * ic, inArr, 0, 0, iw * ic, ih,
cudaMemcpyDeviceToDevice, gPostSR->getCudaStream());
cudaGraphicsUnmapResources(1, &inputRes, gPostSR->getCudaStream());
bool ret = gPostSR->infer();
cudaArray_t outArr;
cudaGraphicsMapResources(1, &outputRes, gPostSR->getCudaStream());
cudaGraphicsSubResourceGetMappedArray(&outArr, outputRes, 0, 0);
cudaMemcpy2DToArrayAsync(outArr, 0, 0, gPostSR->outputBuffer(), ow * oc, ow * oc, oh,
cudaMemcpyDeviceToDevice, gPostSR->getCudaStream());
cudaGraphicsUnmapResources(1, &outputRes, gPostSR->getCudaStream());
This loop is called by the OnRenderImage() in Unity. The input and output resources are registered before entering this loop (cudaGraphicsD3D11RegisterResource).
for the first few loops it runs ok. But soon it will crash into nvwgf2umx.dll.
I debugged it a little. Finding that before crashing into the driver dll, the cudaGraphicsMapResources returns cudaErrorUnknown. I don’t know which one is the root cause. Please help me with advice on how to debug further.
My environment:
Windows 11 22H2
nvidia driver 31.0.15.3818
cuda sdk: 11.7.0
Unity 2023.2.20f1c1
graphic card: rtx4070 laptop
attaching debug output from visual studio
log.txt (101.8 KB)