Hi!
This may be a basic question, but I would appreciate an answer.
Is there a limit to the number of rays in OptiX 7.0.0?
I am using IAS and GAS to move a polyhedral model to multiple postures, and ray tracing is performed on each of them to determine contact. However, as the number of rays and postures increase, the “out of memory” GPU memory is exhausted.
I can’t solve this problem, and I thought there might be something wrong with it as well as the limitation on the number of triangle polygon inputs.
A lot more information about your scene setup and size, launch dimensions, and the ray tracing programs and their algorithm would be required to be able to tell exactly why you run into out of memory (OOM) issues.
Also when does that happen? Before launching or inside a launch?
There are a number limits in OptiX 7 for the number of primitives in a GAS, the number of instances in an IAS, the number of launch indices, etc.
You should check the following things:
I am using IAS and GAS to move a polyhedral model to multiple postures, and ray tracing is performed on each of them to determine contact. However, as the number of rays and postures increase, the “out of memory” GPU memory is exhausted.
There is a maximum launch size implied by the driver which is 2^30 in OptiX 7.
(That is not necessarily the number of optixTrace() calls executed in your ray tracing kernel.) https://forums.developer.nvidia.com/t/3d-optixlaunch-to-accommodate-multiple-viewpoints/160421/2
If you exceed the maximum launch dimension, then you’d need to partition your algorithm into multiple launches with a “do less work more often” approach. That will also prevent driver timeouts on Windows OS systems (the infamous Timeout Detection and Recovery, TDR).
Kernel launches or any other OptiX API calls taking a stream argument are asynchronous, so the per launch overhead can be minimized.
If you exceed the number of instances in an IAS, OptiX allows deeper IAS hierarchies than a single level at a slightly increased BVH traversal cost.
Explicitly calculate your stack space. The OptiX SDK examples show how. This is per thread, so the larger your launch dimension, the more VRAM this uses. Try to make this as small as possible. If your algorithm is recursive, try to rewrite it to be iterative. Unidirectional path tracers will use the smallest stack. https://raytracing-docs.nvidia.com/optix7/guide/index.html#program_pipeline_creation#pipeline-stack-size
Try to make your per-ray payload and any number of variables inside your device programs as small as possible.
I would generally recommend to update to the latest available OptiX SDK release (7.3 at this time). Please read the OptiX Release Notes for changes to the API and required display drivers. There have been some small API changes to the IAS AABB field (removed) and the denoiser.
I’m sorry for the delay in checking various factors. Based on the answer of “Optix 7.0 memory error”, I think the problem may be in the process of moving triangle polygons using IAS.
In my program, I keep calling a single rotation matrix in a 「for」 statement. I kept overwriting one IAS and performing ray tracing on the moved solid.
I know from the program guide [5.5 Relocation] that I need to reposition the IAS, but I don’t know how to do it.
I can do one move in the sample program.
First, if you get an out of memory error because you’re constantly rebuilding the acceleration structure, make sure that you correctly manage the underlying CUDA allocations for all CUdevicptr used on those steps.
Otherwise you’re leaking VRAM memory and it would not be surprising that there is an OOM condition after some time.
If you change the matrix inside an instance to transform that underlying IAS or GAS, then the IAS either needs to be rebuild or updated (refitted) before the next launch.
Both is done with the optixAccelBuild() call using different build operations.
You must do that for every acceleration structure which changed and for each IAS which is above any changed acceleration structure up to the root AS of your scene.
If you search the OptiX SDK examples for OPTIX_BUILD_OPERATION_UPDATE you’ll find examples doing that.
One of my OptiX 7 advanced examples is also showing that inside the intro_motion_blur updateAnimation() function.
AS relocation has nothing to do with that! That only needs to be done whenever you copy or move the CUDA data of an AS pointed to by a CUdeviceptr to another pointer.