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

An error occurred while loading data using torch_geometric.datasets.Planetoid #326

Closed
wants to merge 1 commit into from

Conversation

LinkJam0
Copy link

@LinkJam0 LinkJam0 commented Jun 6, 2024

When using torch_geometry.datasets.Planetoid to load data on a Mac, an error message Could not run 'pyg::index_sort' with arguments from the 'CPU' backend. The error message states that pyg::index_sort 'is only available for these backups: [CUDA, MPS, Meta, BackendSelect, Python, FuncTorchDynamicLayerBackMode, Functionalize, Named, Conjugate, Negative, ZeroTens: Or, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradMPS, AutogradXPU, AutogradHPU, AutogradLazy, AutogradMeta, Tracer, AutocastCPU, AutocastCUDA, FuncTorchBatched, BatchedNestedTensor, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, Python TLSSnap, FuncTorchDynamicLayerFrontMode, PreDisp [attach, Python Dispatcher]

After debugging the source code, I found that there was an issue with the if check in the function definition of index_sort(). This is because when loading the dataset, CPU mode is used by default, and the value of is_cpu should be true. In this case, torch.sort() should be used instead of torch.ops.pyg.index_sort(). This error will not appear on devices using CUDA, but will cause errors in dataset loading on devices using CPU by default.

… an error message "Could not run 'pyg::index_sort' with arguments from the 'CPU' backend. '" The error message states that' pyg::index_sort 'is only available for these backups: [CUDA, MPS, Meta, BackendSelect, Python, FuncTorchDynamicLayerBackMode, Functionalize, Named, Conjugate, Negative, ZeroTens: Or, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradMPS, AutogradXPU, AutogradHPU, AutogradLazy, AutogradMeta, Tracer, AutocastCPU, AutocastCUDA, FuncTorchBatched, BatchedNestedTensor, FuncTorchVmapMode, Batched, VmapMode, FuncTorchGradWrapper, Python TLSSnap, FuncTorchDynamicLayerFrontMode, PreDisp [attach, Python Dispatcher]“

After debugging the source code, I found that there was an issue with the if check in the function definition of "index_sort()". This is because when loading the dataset, CPU mode is used by default, and the value of "is_cpu" should be true. In this case, "torch. sort()" should be used instead of "torch. ops. pyg. index_sort()". This error will not appear on devices using CUDA, but will cause errors in dataset loading on devices using CPU by default.
@rusty1s
Copy link
Member

rusty1s commented Jun 14, 2024

I don't think that's correct. This seems to be more of a problem with a failed pyg-lib installation (and not correctly treating this downstream in PyG). index_sort in pyg-lib only has a CPU implementation, and so we only call it in case the tensor sits on CPU.

@rusty1s rusty1s added the stale label Jun 14, 2024
@akihironitta akihironitta changed the title An error occurred while loading data using "torch geometry. datasets. Planetoid" An error occurred while loading data using torchgeometric.datasets.Planetoid Jul 19, 2024
@akihironitta akihironitta changed the title An error occurred while loading data using torchgeometric.datasets.Planetoid An error occurred while loading data using torch_geometric.datasets.Planetoid Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants