Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

CUDA runtime error when running extract_triangle_mesh() from o3d.t.geometry.VoxelBlockGrid()

Open dalnoguer opened this issue 3 years ago • 3 comments

Checklist

My Question

Hello,

Thanks for your great work :)

I am running into the following error when extracting a triangle mesh from a VoxelBlockGrid. Integrating each pair color/depth works fine, but when I try to extract the triangle mesh I get the following error:

    mesh = volume.extract_triangle_mesh()
RuntimeError: [Open3D Error] (void open3d::core::__OPEN3D_CUDA_CHECK(cudaError_t, const char*, int)) /root/Open3D/cpp/open3d/core/CUDAUtils.cpp:301: /root/Open3D/cpp/open3d/core/MemoryManagerCUDA.cpp:91 CUDA runtime error: an illegal memory access was encountered

Additionally, if I try to save the voxelblockgrid and load it again, I get a bunch of index out of bounds errors.

Here is the piece of code I used:

volume = o3d.t.geometry.VoxelBlockGrid(
    attr_names=("tsdf", "weight", "color"),
    attr_dtypes=(o3c.float32, o3c.float32, o3c.float32),
    attr_channels=((1), (1), (3)),
    voxel_size=3.0 / 512,
    block_resolution=16,
    block_count=50000,
    device=o3d.core.Device("CUDA:0"),
)

for i in tqdm.tqdm(range(len(rgbd_frames))):
    color = o3d.t.io.read_image(str(image_dir.joinpath(rgbd_frames[i]))).to(
        o3d.core.Device("CUDA:0")
    )
    depth = o3d.t.io.read_image(str(depth_dir.joinpath(rgbd_frames[i]))).to(
        o3d.core.Device("CUDA:0")
    )

    intrinsics = o3d.core.Tensor(
        camera_intrinsics[recording_id].intrinsic_matrix,
    )
    extrinsics = o3d.core.Tensor(
        np.linalg.inv(camera.parameters[i].extrinsic),
    )
    frustum_block_coords = volume.compute_unique_block_coordinates(
        depth, intrinsics, extrinsics, depth_max=self.depth_trunc
    )

    volume.integrate(
        frustum_block_coords,
        depth,
        color,
        intrinsics,
        extrinsics,
        depth_max=self.depth_trunc,
    )

mesh = volume.extract_triangle_mesh()

What am I missing? I checked if the gpu was full but only 8/16 GB were being used.

Thanks!

dalnoguer avatar Mar 01 '22 10:03 dalnoguer

Does extract_point_cloud work? Current extract_triangle_mesh is a bit expensive and requires a lot of additional memory. I will have to rewrite it someday...

theNded avatar Mar 02 '22 15:03 theNded

@theNded I can confirm that on my configuration extract_point_cloud works. I'm having the same problem on my RTX 3070 laptop however it seems to be ok on my desktop with RTX 2070 Super. They both have 8GB RAM and I'm running the same scene on both devices and the only difference is that my open3d version on my desktop is open3d-0.13.0+4dd197ce2 vs open3d-0.15.2+97960f23 on my laptop. I haven't had a chance to build 0.13 on my laptop yet and will make sure to update here once I test it.

ozgucbertug avatar May 03 '22 04:05 ozgucbertug

Does extract_point_cloud work? Current extract_triangle_mesh is a bit expensive and requires a lot of additional memory. I will have to rewrite it someday...

extract_triangle_mesh

After each call to extract_triangle_mesh, the GPU memory is not released. Is there any solution to this issue?

small-zeng avatar May 28 '24 14:05 small-zeng