-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tensor TriangleMesh.from_legacy() using python multiprocessing gets stuck in waiting. #4923
Comments
Any update on this? |
How is the example related to raycasting? |
The call to import multiprocessing
import open3d as o3d
def ray_cast(i):
# Load mesh and convert to open3d.t.geometry.TriangleMesh
cube = o3d.geometry.TriangleMesh.create_box().translate([0, 0, 0])
cube = o3d.t.geometry.TriangleMesh.from_legacy(cube)
# Create a scene and add the triangle mesh
scene = o3d.t.geometry.RaycastingScene()
cube_id = scene.add_triangles(cube)
# The first ray starts at (0.5,0.5,10) and has direction (0,0,-1).
# The second ray start at (-1,-1,-1) and has direction (0,0,-1).
rays = o3d.core.Tensor([
[0.5, 0.5, 10, 0, 0, -1],
[-1, -1, -1, 0, 0, -1]
], dtype=o3d.core.Dtype.Float32)
ans = scene.cast_rays(rays)
print(ans)
# Serial ray cast
ray_cast(0)
parallel_jobs = 3
pool = multiprocessing.Pool(parallel_jobs)
list = [1, 2, 3]
pool.map(ray_cast, list) |
OK, so the problem it is not related to RaycastingScene. I changed the title to reflect this. Can you reproduce the problem without reading data by creating meshes for example with TriangleMesh.create_sphere()? |
I think this should be the same as the example I posted previously, just creating a sphere instead of a box. Same issue though: import multiprocessing
import open3d as o3d
def create_triangle_mesh_from_legacy(i):
sphere = o3d.geometry.TriangleMesh.create_sphere()
print("Sphere created")
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)
print("Sphere converted to TriangleMesh from legacy")
# Serial
create_triangle_mesh_from_legacy(0)
parallel_jobs = 3
pool = multiprocessing.Pool(parallel_jobs)
pool.map(create_triangle_mesh_from_legacy, [1, 2, 3]) |
You need to create the processes in import multiprocessing
import open3d as o3d
def create_triangle_mesh_from_legacy(i):
sphere = o3d.geometry.TriangleMesh.create_sphere()
print("Sphere created")
sphere = o3d.t.geometry.TriangleMesh.from_legacy(sphere)
print("Sphere converted to TriangleMesh from legacy")
if __name__ == '__main__':
parallel_jobs = 3
pool = multiprocessing.Pool(parallel_jobs)
pool.map(create_triangle_mesh_from_legacy, [1, 2, 3]) |
That doesn't change anything for me, does that work for you? |
Can you try to add ...
if __name__ == '__main__':
multiprocessing.set_start_method('spawn') # or 'forkserver'
... |
@jordanott Did changing the start method fix the problem for you? |
Yes, changing the start method fixes the waiting issue. |
The raycasting itself is multithreaded. If you have many rays then probably there is not much benefit of processing meshes in parallel. |
Checklist
master
branch).Describe the issue
Hello everyone,
I am trying to speed up the raycasting scene by using python multiprocessing.
Loading the mesh in legacy format is fine, but when I try to convert the mesh to tensor format it gets stuck in waiting.
Steps to reproduce the bug
Error message
It gets stuck, no error message.
When I terminate the program I get this:
Expected behavior
I would expect to run in parallel, since the mesh is around 70MB and there is plenty of memory.
Open3D, Python and System information
The text was updated successfully, but these errors were encountered: