Skip to content
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

Out of memory crash on loading mesh, fixable with small change #42

Open
thegnarwhals opened this issue Apr 11, 2023 · 1 comment
Open

Comments

@thegnarwhals
Copy link

thegnarwhals commented Apr 11, 2023

0a6acbe0724b4fd0901b5a42c19c8952.zip

This is a zipped .glb scene containing a car. Unzipping and running the following script

import numpy as np
import trimesh
from mesh_to_sdf import mesh_to_sdf

model_path = "0a6acbe0724b4fd0901b5a42c19c8952.glb"
mesh = trimesh.load(model_path)
sample_points = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]])
sdf = mesh_to_sdf(mesh, sample_points, surface_point_method="scan", sign_method="depth")
print(sdf)

gives

Killed (out of memory)

Having debugged, this has been narrowed down to the line near the top of __init__.py:

        mesh = mesh.dump().sum()

which calls sum() on a numpy array of Trimesh. This apparently does some parallelisation which is too memory intensive for this geometry. If we do

        mesh = mesh.dump(concatenate=True)

which uses trimesh's inbuilt mesh concatenation, the script completes with expected output

[-0.4379601  0.8417097  2.3150892]

I will open a pull request with this change.

@xiexh20
Copy link

xiexh20 commented Jun 14, 2023

I had the same issue, I tried your fix but it still raised OOM error (killed), the mesh I use is from shapenet: ShapeNetCore.v2/04256520/ccb08f869edde5e6d8adf1ca87495d41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants