An error occurred while loading data using torch_geometric.datasets.Planetoid
#326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using
torch_geometry.datasets.Planetoid
to load data on a Mac, an error messageCould not run 'pyg::index_sort' with arguments from the 'CPU' backend.
The error message states thatpyg::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 ofis_cpu
should be true. In this case,torch.sort()
should be used instead oftorch.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.