Concurrency Issues with Optix/CUDA Disk Cache

Can someone tell me the correct way to avoid problems if two instances of an Optix application are trying to rebuild the Optix disk cache at the same time?

Hey @sosfx, good question!

There are a few different possibilities, so let me ask a couple of questions. If you’re running multiple OptiX apps at the same time, the first question is what do you want to have happen? Would you like to allow each one to rebuild itself separately, or do you want one of them to rebuild and the other one to take advantage of a hot cache? Or do you want to circumvent the cache entirely? I assume you are using OptiX 7?

OptiX 7 has some API calls for managing cache behavior. So if you want each program to have it’s own cache, take a look at optixDeviceContextSetCacheLocation(). You could also disable caching for one or multiple of your concurrent runs using optixDeviceContextSetCacheEnabled().

If you want to use a shared cache, then I might recommend having a pre-process where you run a single known app that will do just enough work to make sure the cache is rebuilt, but not waste time rendering. Then after that, syncronize and launch multiple applications that can read from the shared cache and shouldn’t need to recompile.

Will any of those options work for you?


We are using OptiX 7, so it’s good to know about the API calls for managing cache behavior. Your last suggestion to create a pre-process to ensure the cache is rebuilt is what we were considering. This is very helpful, thank you.

1 Like

Sounds good. Let us know if you run into any issues with this solution. I forgot to mention: please note that doing nothing is functionally acceptable. It will work if you allow multiple apps to try to compile at the same time. The CPU side of your machine is going to spend redundant effort recompiling the same OptiX shader programs, and the cache will be written to with the same data multiple times, but that is the extent of the downsides. You won’t have any issues with cache corruption or failing processes, your machine will just waste some time compiling identical shaders in parallel.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.