isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.43k stars 2.31k forks source link

compute_fpfh_feature hanging if excecuted inside a multiprocessing.Process #6096

Open amarion35 opened 1 year ago

amarion35 commented 1 year ago

Checklist

Describe the issue

If the function o3d.pipelines.registration.compute_fpfh_feature is excecuted inside a Process that is not the main one, it never exits the function. It works fine with Threads though.

[input]

from multiprocessing import Process
import open3d as o3d
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)

path = "any/pointcloud/file.pcd"
pcd = o3d.io.read_point_cloud(path)

def compute_fpfh(pcd):
    print("start")
    pcd_fpfh = o3d.pipelines.registration.compute_fpfh_feature(
        pcd,
        o3d.geometry.KDTreeSearchParamHybrid(radius=1, max_nn=100)
    )
    print("end")
    return pcd_fpfh

[input]

compute_fpfh(pcd)

[output]

start
end

Feature class with dimension = 33 and num = 1000
Access its data via data member.

[input]

process = Process(
    target=compute_fpfh,
    args=(pcd,)
)
process.start()
process.join()

[output]

start

Steps to reproduce the bug

from multiprocessing import Process
import open3d as o3d
o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Debug)

path = "any/pointcloud/file.pcd"
pcd = o3d.io.read_point_cloud(path)

def compute_fpfh(pcd):
    print("start")
    pcd_fpfh = o3d.pipelines.registration.compute_fpfh_feature(
        pcd,
        o3d.geometry.KDTreeSearchParamHybrid(radius=1, max_nn=100)
    )
    print("end")
    return pcd_fpfh

compute_fpfh(pcd)
process = Process(
    target=compute_fpfh,
    args=(pcd,)
)
process.start()
process.join()

Error message

No response

Expected behavior

No response

Open3D, Python and System information

- Operating system: Ubuntu 20.04 (WSL)
- Python version: Python 3.8
- Open3D version: 0.16.1+1c84344a
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): ?

Additional information

No response

yuecideng commented 1 year ago

Hi @amarion35, this is because the pybinding of compute_fpfh_feature does not realsed python GIL. The problem is common among legacy API, and might be fixed in PR #5888