Hi,
I have recently started a project on ray tracing using OptiX.
Exact function call looks something like this:
This can be found in the open source code base : 3dgrut/threedgrt_tracer/tracer.py at main · nv-tlabs/3dgrut · GitHub
(self.frame_timer is a CudaTimer)
def render(self, gaussians, gpu_batch: Batch, train=False, frame_id=0):
num_gaussians = gaussians.num_gaussians
with torch.cuda.nvtx.range(f"model.forward({num_gaussians} gaussians)"):
if self.frame_timer is not None:
self.frame_timer.start()
(pred_rgb, pred_opacity, pred_dist, pred_normals, hits_count, mog_visibility) = Tracer._Autograd.apply(
self.tracer_wrapper,
frame_id,
gpu_batch.T_to_world.contiguous(),
gpu_batch.rays_ori.contiguous(),
gpu_batch.rays_dir.contiguous(),
gaussians.positions.contiguous(),
gaussians.get_rotation().contiguous(),
gaussians.get_scale().contiguous(),
gaussians.get_density().contiguous(),
gaussians.get_features().contiguous(),
Tracer.RenderOpts.DEFAULT,
gaussians.n_active_features,
self.conf.render.min_transmittance,
)
if self.frame_timer is not None:
self.frame_timer.end()
pred_rgb, pred_opacity = gaussians.background(
gpu_batch.T_to_world.contiguous(), gpu_batch.rays_dir.contiguous(), pred_rgb, pred_opacity, train
)
if self.frame_timer is not None:
self.timings["forward_render"] = self.frame_timer.timing()
return {
"pred_rgb": pred_rgb,
"pred_opacity": pred_opacity,
"pred_dist": pred_dist,
"pred_normals": torch.nn.functional.normalize(pred_normals, dim=3),
"hits_count": hits_count,
"frame_time_ms": self.frame_timer.timing() if self.frame_timer is not None else 0.0,
"mog_visibility": mog_visibility,
}
When i measure this CudaTimer, value comes out to be lesser than the value shown in NVIDIA NSight Profiler in CUDA HW optixLaunch, by around 80ms. At the same time, time in nvtx range “model.forward({num_gaussians} gaussians)” comes out to be 60 micro seconds.
I want to understand what is CudaTimer measuring here? I know that optixLaunch could be asynchronous, but that would result CudaTimer to show very small value(in micro seconds)
I’m trying to experiment with forward rendering times, and trying to understand what is happening here. Any help would mean a lot to me. Thank you.
