Skip to content

Faces list creation does not work on MacOS #1802

Open
@mxrcooo

Description

@mxrcooo

🐛 Bugs / Unexpected behaviors

I'm trying to load an obj file (on MacOS) using load_obj and create a Meshes instance:

mesh_pytorch3d = Meshes(verts=[verts], faces=[faces], textures=textures)

The code gets stuck here and after profiling I found that this line is what causes it to get stuck: https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/structures/meshes.py#L347

It loads fine for the same object on an Ubuntu server with a GPU but it doesn't work on my MacBook (M3 Pro Max). I installed Pytorch3D following the INSTALL.md steps with: MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install "git+https://github.com/facebookresearch/pytorch3d.git"

The following debug print also times out:

print("test:", faces[0][faces[0].gt(-1).all(1)])

The obj file is tr_reg_000_for_illustration from the FAUST dataset.

I'm not sure if this issue is Pytorch3D related or torch related. I think the issue is the mask access f[mask]. When rewriting the logic to this, it works:

self._faces_list = []

for f in faces:
    if len(f) > 0:
        valid_rows = []
        for row in f:
            if torch.all(row > -1):
                valid_rows.append(row)
        if valid_rows:
            filtered_f = torch.stack(valid_rows).to(torch.int64)
        else:
            filtered_f = torch.tensor([]).to(f.dtype)
    else:
        filtered_f = f

    self._faces_list.append(filtered_f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions