Search code examples
pytorchpytorch-geometricgraph-neural-network

torch_geometric.nn radius_graph example giving AttributeError


when trying to execute the example code for radius_graph from torch_geometric i get the following error:

File "C:\Users\nico_\AppData\Local\Programs\Python\Python38\lib\site-packages\torch_geometric\nn\pool\__init__.py", line 210, in radius_graph
    return torch_cluster.radius_graph(x, r, batch, loop, max_num_neighbors,
AttributeError: 'NoneType' object has no attribute 'radius_graph'

the code giving the error is https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.nn.pool.radius_graph.html#torch_geometric.nn.pool.radius_graph

import torch
from torch_geometric.nn import radius_graph

x = torch.Tensor([[-1, -1], [-1, 1], [1, -1], [1, 1]])
batch = torch.tensor([0, 0, 0, 0])
edge_index = radius_graph(x, r=1.5, batch=batch, loop=False)

i tried also to import from torch_geometric.nn.pool but gives the same error as if it doesn't find the funcion.

I'm using python 3.8 with VScode in windows 11

edit: I tried setting a venv in pycharm just for this project and now the problem has shifted to installing torch_cluster (same problem both for torch 1.13 and 2.0): after installing torch_geometric 2.3.0 i type the command

pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-1.13.0+cpu.html

(with the last part torch-xxx+cpu.html 1.13 or 2.0 when trying with torch 1.13 or 2.0, both didn't work) it gives me this error:

Looking in links: https://data.pyg.org/whl/torch-1.13.0+cpu.html
ERROR: Could not find a version that satisfies the requirement pyg_lib (from versions: none)
ERROR: No matching distribution found for pyg_lib

thank you so far for the help


Solution

  • Reinstalling everything solved the problem as always, the working dependencies are torch -> 2.0.0+cpu, torch_gemetric -> 2.3.0, torch_cluster -> 1.6.1+pt20cpu, python -> 3.8