Hi, I am currently porting our application to Optix 8.0, but meanwhile I also need to maintain the 6.5 version. Recently I ran into some issues when using the latter.
I apologize in advance for giving only limited information pertaining to our code, but hopefully it’s enough to shed some light on what’s going on.
Whenever our application begins a certain process, the Optix context is created, and then destroyed once the process is completed. When the process is initiated once more, new Optix context is created. At the same time, there is unrelated Cuda code that runs in parallel which I hope is not affected by the aforementioned manipulations. Detlef mentions the following in response to the post below:
OptiX 1 - 6 use the existing primary CUDA context on the device
- I wonder, does destroying Optix context happen to invalidate the primary Cuda context as well?
So far we haven’t had any issues, but we’ve been steadily increasing the complexity of our scenes. And recently we started having weird rendering artifacts (among other things).
Some of our Optix and Cuda kernels share texture objects (RTtexturesampler
). The sampler is created via context->createTextureSampler()).
We bind it to optix rtTextureSampler
via optix::Variable::set(sampler)
, whereas to use it in Cuda we simply pass sampler->getId()
to the kernel, and inside the kernel cast the Id to cudaTextureObject_t
so that it can be sampled from via tex3d
.
As I mentioned, up until recently everything was fine. However now once the Optix context is recreated, the image turns black. I printed out the values that are sampled from the texture (cuda printf
), and they always amount to zero, regardless of what I put inside the texture.
I then decided to query the texture object via cudaGetTextureObjectResourceViewDesc(struct cudaResourceViewDesc *pResViewDesc, cudaTextureObject_t texObject)
, which is a function in cuda_runtime_api.h
. To be completely candid, I am not sure the values I am seeing in the output struct is what I expected. But having said that, the application does not crash in the first run. However, once again after context recreation, I am getting the following error:
Unknown error (Details: Function "_rtContextLaunch2D" caught exception: Encountered a CUDA error: cudaDriver().CuMemcpyHtoDAsync( dstDevice, srcHost, byteCount, stream.get() ) returned (709): Context has been destroyed, file: <internal>, line: 0)
And I am not sure how that relates to the texture query I did above, but removing cudaGetTextureObjectResourceViewDesc
also makes the error message disappear.
Does anyone happen to know what could be happening here? Thanks!