Skip to content

Fix scatter_ runtime error: size of index should be smaller than src #1067

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

Closed
wants to merge 1 commit into from

Conversation

kylelo
Copy link
Contributor

@kylelo kylelo commented Feb 7, 2022

Error Reproduction:

python=3.8.12
pytorch=1.9.1
pytorch3d=0.6.1
cudatoolkit=11.1.74

test.py:

import torch
from pytorch3d.ops import cubify
voxels = torch.Tensor([[[[0,1], [0,0]], [[0,1], [0,0]]]]).float()
meshes = cubify(voxels, 0.5, device="cpu")

The error appears when device="cpu" and pytorch=1.9.1 (works fine with pytorch=1.10.2)

Error message:

/home/kyle/anaconda3/envs/adapt-net/lib/python3.8/site-packages/torch/_tensor.py:575: UserWarning: floor_divide is deprecated, and will be removed in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values.
To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). (Triggered internally at  /opt/conda/conda-bld/pytorch_1631630839582/work/aten/src/ATen/native/BinaryOps.cpp:467.)
  return torch.floor_divide(self, other)
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    meshes = cubify(voxels, 0.5, device="cpu")
  File "/home/kyle/anaconda3/envs/adapt-net/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "/home/kyle/Desktop/pytorch3d/pytorch3d/ops/cubify.py", line 227, in cubify
    idleverts.scatter_(0, grid_faces.flatten(), 0)
RuntimeError: Expected index [60] to be smaller than self [27] apart from dimension 0 and to be smaller size than src [27]

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 7, 2022
@facebook-github-bot
Copy link
Contributor

@bottler has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bottler
Copy link
Contributor

bottler commented Apr 5, 2022

Thank you for sorting this out!

@kylelo
Copy link
Contributor Author

kylelo commented Apr 9, 2022

You're welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants