facebookresearch / facebookresearch/pytorch3d

Faces list creation does not work on MacOS

Open
#1,802 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

🐛 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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the FAUST OBJ case on macOS, then inspect pytorch3d/structures/meshes.py around line 347 and the reported faces[0][faces[0].gt(-1).all(1)] expression. Compare the behavior with the Ubuntu setup to determine whether the hang is in PyTorch or PyTorch3D; done means the same Meshes construction completes reliably on the affected platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.