pytorch_cluster icon indicating copy to clipboard operation
pytorch_cluster copied to clipboard

[MPS] PyTorch Nightly with MPS on Mac M1 does not work

Open nicolas-schreiber opened this issue 2 years ago • 3 comments
trafficstars

Hi, I am currently trying to get pytorch geometric to run on my Mac with M1 Pro, the recent update to 13.3 fixed quite a few things. Look here for a bit more info about that: https://github.com/pytorch/pytorch/issues/96610

But currently I have following error message that points towards pytorch_cluster:

Traceback (most recent call last):
  File "/Users/nic/Projects/pytorch_geometric/examples/pointnet2_classification.py", line 104, in <module>
    train(epoch)
  File "/Users/nic/Projects/pytorch_geometric/examples/pointnet2_classification.py", line 70, in train
    loss = F.nll_loss(model(data), data.y)
  File "/Users/nic/mambaforge/envs/imitation/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/Users/nic/Projects/pytorch_geometric/examples/pointnet2_classification.py", line 56, in forward
    sa1_out = self.sa1_module(*sa0_out)
  File "/Users/nic/mambaforge/envs/imitation/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/Users/nic/Projects/pytorch_geometric/examples/pointnet2_classification.py", line 20, in forward
    idx = fps(pos, batch, ratio=self.ratio)
  File "/Users/nic/mambaforge/envs/imitation/lib/python3.9/site-packages/torch_geometric/nn/pool/__init__.py", line 51, in fps
    return torch_cluster.fps(x, batch, ratio, random_start)
  File "/Users/nic/mambaforge/envs/imitation/lib/python3.9/site-packages/torch_cluster/fps.py", line 70, in fps
    return torch.ops.torch_cluster.fps(src, ptr, r, random_start)
  File "/Users/nic/mambaforge/envs/imitation/lib/python3.9/site-packages/torch/_ops.py", line 642, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: src.device().is_cpu() INTERNAL ASSERT FAILED at "csrc/cpu/fps_cpu.cpp":14, please report a bug to PyTorch. src must be CPU tensor

To replicate this I just change the device in pytorch_geometric/examples/pointnet2_classification.py to mps

My current installed packages are following:

torch                     2.1.0.dev20230331          pypi_0    pypi
torch-cluster             1.6.1                    pypi_0    pypi
torch-geometric           2.3.0                    pypi_0    pypi
torch-scatter             2.1.1                    pypi_0    pypi
torch-sparse              0.6.17                   pypi_0    pypi
torchaudio                2.0.0.dev20230313          pypi_0    pypi
torchvision               0.16.0.dev20230331          pypi_0    pypi

So a lot of nightly things. I know that this makes the support quite difficult, but maybe someone can still point me to a solution to this issue.

nicolas-schreiber avatar Mar 31 '23 12:03 nicolas-schreiber

Hm, ok I might've just realised that one would have to specifically implement code for the MPS interfaces which are currently not implemented and might be not too easy to implement, so I guess I am going back to CPU based tests...

Do I understand the issue correctly? If so the issue can be closed

nicolas-schreiber avatar Mar 31 '23 12:03 nicolas-schreiber

Yes, I am sorry. We don‘t have any MPS-specific implementation right now. You might be able to convert to CPU before calling the cluster routines, and back to MPS afterwards.

rusty1s avatar Apr 02 '23 06:04 rusty1s

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

github-actions[bot] avatar Sep 30 '23 00:09 github-actions[bot]