ashawkey / cubvh

CUDA Mesh BVH tools.
MIT License
166 stars 13 forks source link

Extremely slow in initialisation of cuBVH #18

Open YZsZY opened 3 months ago

YZsZY commented 3 months ago

Hello author~ Recently I've been testing cuBVH in RTX 3070, torch 2.1.0, cuda 11.8, ubuntu 20 and I found that when initializing the mesh is extremely slow and takes half an hour, however, the same mesh using raytracing initialises in just 10 seconds or so, I'd like to ask you if you've encountered this problem!

import cubvh
import raytracing
import trimesh

mesh_file = "XXX.obj"
scene_mesh = trimesh.load(mesh_file)
scene_tracer = cubvh.cuBVH(scene_mesh.vertices,scene_mesh.faces)  # raytracing.RayTracer(scene_mesh.vertices, scene_mesh.faces)
YZsZY commented 3 months ago

I install cuBVH in RTX 4070, torch-1.13.0-cu117, initializing the same mesh file is very fast, but in RTX 3070,torch-2.1.0-cu118 is very slow T-T

ashawkey commented 3 months ago

@YZsZY Hi, it sounds strange as the raytracing package almost uses the same code as cubvh. Have you tried running several times and average the time? The first run's time maybe inaccurate.

YZsZY commented 3 months ago

@ashawkey Hi, thanks for the reply~ I tested it on two different sizes of mesh, the speed is similar on a very simple mesh, but on a very complex mesh (scannet++) the difference is huge, I encountered this on 3060, 3070, and A100 with cuda11.8+torch2.1.0,it's really strange T-T.

With a complex mesh: lX4HqbsnRA ScreenCapture_2024-08-07-11-19-31

With a simple mesh: lHQS0duvZs ScreenCapture_2024-08-07-11-21-01

HarukiZhang commented 3 months ago

Hello, guys, I have also encountered this slow initialization.

In my case,

When I tried to initialize cubvh with a scene that contains 3773056 vertices and 7155510 faces, it takes 323 seconds for initialization and 0.001568 sec for .ray_tracing() for 2^20 rays;

I wonder whether this initiliazation time comsumption is normal?

ashawkey commented 3 months ago

@HarukiZhang I guess at this level of vertices and triangles, it's normal.