# Optix7 crashes in optixDeviceContextCreate

**URL:** <https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587>\
**Category:** OptiX\
**Created:** [November 18, 2019, 7:21am UTC](https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587 "2019-11-18T07:21:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lythm780522](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lythm780522](https://forums.developer.nvidia.com/u/lythm780522)\
**Post date:** [November 18, 2019, 7:21am UTC](https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587/1 "2019-11-18T07:21:29Z")

</div>

hi all:  
we are using Optix7 to bake lightmaps, sometimes optix crashes in optixDeviceContextCreate.

os: windows 10  
driver: 441.12  
graphics card: GTX2080TI x 2

optixInit is called in main thread to load optix funtion table when program start, then two renderthreads are spawned. Each thread creates one optix context with cudaContext 0 passed into optixDeviceContextCreate. The logics looks like this:

program start:  
main thread:  
optixInit  
spawn renderthread

for each baking job:  
reanderthread:  
create optix context  
rendering…  
destroy optix context  
cudaDeviceSync  
cudaDeviceReset

then after several hours, optix crashed in optixDeviceContextCreate. Is it ok to create and destroy optix context upon each baking?

call stack:  
ntdll.dll!RtlReportCriticalFailure() Unknown  
ntdll.dll!RtlpHeapHandleError() Unknown  
ntdll.dll!RtlpHpHeapHandleError() Unknown  
ntdll.dll!RtlpLogHeapFailure() Unknown  
ntdll.dll!RtlFreeHeap() Unknown  
nvfatbinaryLoader.dll!00007ffcdc800228() Unknown

> nvfatbinaryLoader.dll!00007ffcdc777517() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc773efa() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc773aa2() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc7747c8() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc76524b() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc763686() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc7308bd() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc73052b() Unknown  
> nvfatbinaryLoader.dll!00007ffcdc72f984() Unknown  
> nvrtum64.dll!00007ffcb0af8b3c() Unknown  
> nvrtum64.dll!00007ffcb0af8a72() Unknown  
> nvrtum64.dll!00007ffcb0a8cc39() Unknown  
> nvrtum64.dll!00007ffcb0a8bff1() Unknown  
> nvrtum64.dll!00007ffcb0a8f475() Unknown  
> nvoptix.dll!00007ffccbfae550() Unknown  
> nvoptix.dll!00007ffccbfb5a1b() Unknown  
> rendernode.exe!pt::OptixUtils::CreateOptixContext(const std::experimental::filesystem::v1::path & cachePath) Line 33 C++  
> rendernode.exe!pt::PTRenderer::Init(unsigned int deviceId, std::shared\_ptr scene, unsigned int optBits) Line 124 C++  
> rendernode.exe!RenderDevice::RenderThread\_InitRenderer(std::shared\_ptrutils::MemStream sceneData) Line 873 C++  
> rendernode.exe!RenderDevice::RenderThread\_DispatchEvent(const std::shared\_ptrnet::Packet & packet) Line 141 C++  
> rendernode.exe!RenderDevice::RenderThread\_Run() Line 52 C++

any idea ?

---

<div class="post-metadata">

**Author:** ![droettger](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/droettger/32/14043_2.png) [@droettger](https://forums.developer.nvidia.com/u/droettger)\
**Post date:** [November 18, 2019, 8:18am UTC](https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587/2 "2019-11-18T08:18:11Z")

</div>

Yes, there is a known multi-threading issue in functions called by optixDeviceContextCreate which will be fixed in upcoming R440 drivers.  
Until the you would either need to put the optixDeviceContextCreate in a single thread or put a mutex around it to make sure they are not called in parallel.

---

<div class="post-metadata">

**Author:** ![lythm780522](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@lythm780522](https://forums.developer.nvidia.com/u/lythm780522)\
**Post date:** [November 18, 2019, 8:28am UTC](https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587/3 "2019-11-18T08:28:49Z")

</div>

> [@Detlef Roettger](#):
>
> Yes, there is a known multi-threading issue in functions called by optixDeviceContextCreate which will be fixed in upcoming R440 drivers.  
> Until the you would either need to put the optixDeviceContextCreate in a single thread or put a mutex around it to make sure they are not called in parallel.

ok, I will try adding mutex!  
Thank you so much

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [June 14, 2022, 9:05pm UTC](https://forums.developer.nvidia.com/t/optix7-crashes-in-optixdevicecontextcreate/107587/4 "2022-06-14T21:05:32Z")

</div>

Closed on June 14, 2022, 9:05pm UTC


