pyg-team/pyg-lib

`LinkNeighborloader` fails due to `Could not run 'pyg::index_sort' with arguments from the 'CPU' backend`

Closed this issue ยท 19 comments

๐Ÿ› Describe the bug

Screenshot (625)

edge_label_index = train_data["user", "rates", "movie"].edge_label_index
edge_label = train_data["user", "rates", "movie"].edge_label

train_loader = LinkNeighborLoader(
    data=train_data,
    num_neighbors=[20, 10],
    neg_sampling_ratio=2.0,
    edge_label_index=(("user", "rates", "movie"), edge_label_index),
    edge_label=edge_label,
    batch_size=128,
    shuffle=True,
)

# Inspect a sample:
sampled_data = next(iter(train_loader))

print("Sampled mini-batch:")
print("===================")
print(sampled_data)

assert sampled_data["user", "rates", "movie"].edge_label_index.size(1) == 3 * 128
assert sampled_data["user", "rates", "movie"].edge_label.min() == 0
assert sampled_data["user", "rates", "movie"].edge_label.max() == 1`

Environment

  • pyg-lib version:
  • PyTorch version:
  • OS:
  • Python version:
  • CUDA/cuDNN version:
  • How you installed PyTorch and pyg-lib (conda, pip, source):
  • Any other relevant information:

@rusty1s please resolve my issue as soon as possible, i have my presentation this monday!

How did you install pyg-lib and which version?

I have installed using this command:
!pip install --upgrade pyg-lib -f https://data.pyg.org/whl/nightly/torch-2.2.0+cpu.html

actually since 2months eveyrthing was working fine
just today itself I encountered this error

I was using the same code ...and everything was working fine but idk how it happened

@rusty1s I was using the same installation since so many days without facing any errors!!
Using this below command:
!pip install --upgrade pyg-lib -f https://data.pyg.org/whl/nightly/torch-2.2.0+cpu.html

What's the output of

import pyg_lib
import torch

inputs = torch.randperm(100_000)
pyg_lib.ops.index_sort(inputs)

Does that run through?

image
showing the same error with your code snippet too!!!

@rusty1s please see the above!!!

For now, you can unblock yourself with

import torch_geometric
torch_geometric.typing.WITH_INDEX_SORT = False

image
Still showing the same error!! @rusty1s

Yes, but the error will disappear inside LinkNeighborLoader (the original issue).

This is the error I am getting now!!!

image

Please try to tell the solution asap as I have my conference presentation tomorrow for my accepted research paper!!

@rusty1s please see the above

Can you post a reproducible example here (no screenshot)? It's hard to tell what might have gone wrong.

You can also share the colab with me if that is easier.

The issue is that you are re-installing torch. Colab comes with PyTorch pre-installed, so simply do

!pip install torch_geometric torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.3.0+cu121.html
!pip install --upgrade pyg-lib -f https://data.pyg.org/whl/nightly/torch-2.3.0+cu121.html
import pyg_lib
inputs = torch.randperm(100_000)
pyg_lib.ops.index_sort(inputs)

then works

okayy thank you so much!!! its working now