pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.08k stars 3.63k forks source link

ModuleNotFoundError: 'CuGraphSAGEConv' requires 'pylibcugraphops>=23.02' #9310

Closed d3netxer closed 2 months ago

d3netxer commented 4 months ago

😵 Describe the installation problem

I am trying to run this code block:

import torch.nn.functional as F
from torch_geometric.nn import CuGraphSAGEConv

class CuGraphSAGE(torch.nn.Module):
    def __init__(self, in_channels, hidden_channels, out_channels, num_layers):
        super().__init__()

        self.convs = torch.nn.ModuleList()
        self.convs.append(CuGraphSAGEConv(in_channels, hidden_channels))
        for _ in range(num_layers - 1):
            conv = CuGraphSAGEConv(hidden_channels, hidden_channels)
            self.convs.append(conv)

        self.lin = torch.nn.Linear(hidden_channels, out_channels)

    def forward(self, x, edge, size):
        edge_csc = CuGraphSAGEConv.to_csc(edge, (size[0], size[0]))
        for conv in self.convs:
            x = conv(x, edge_csc)[: size[1]]
            x = F.relu(x)
            x = F.dropout(x, p=0.5)

        return self.lin(x)

model = CuGraphSAGE(128, 64, 349, 3).to(torch.float32).to("cuda")
optimizer = torch.optim.Adam(model.parameters(), lr=0.01)

but I get this:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[26], line 25
     21             x = F.dropout(x, p=0.5)
     23         return self.lin(x)
---> 25 model = CuGraphSAGE(128, 64, 349, 3).to(torch.float32).to("cuda")
     26 optimizer = torch.optim.Adam(model.parameters(), lr=0.01)

Cell In[26], line 9, in CuGraphSAGE.__init__(self, in_channels, hidden_channels, out_channels, num_layers)
      6 super().__init__()
      8 self.convs = torch.nn.ModuleList()
----> 9 self.convs.append(CuGraphSAGEConv(in_channels, hidden_channels))
     10 for _ in range(num_layers - 1):
     11     conv = CuGraphSAGEConv(hidden_channels, hidden_channels)

File ~/.conda/envs/rapids-24.04/lib/python3.11/site-packages/torch_geometric/nn/conv/cugraph/sage_conv.py:40, in CuGraphSAGEConv.__init__(self, in_channels, out_channels, aggr, normalize, root_weight, project, bias)
     30 def __init__(
     31     self,
     32     in_channels: int,
   (...)
     38     bias: bool = True,
     39 ):
---> 40     super().__init__()
     42     if aggr not in ['mean', 'sum', 'min', 'max']:
     43         raise ValueError(f"Aggregation function must be either 'mean', "
     44                          f"'sum', 'min' or 'max' (got '{aggr}')")

File ~/.conda/envs/rapids-24.04/lib/python3.11/site-packages/torch_geometric/nn/conv/cugraph/base.py:41, in CuGraphModule.__init__(self)
     38 super().__init__()
     40 if not HAS_PYLIBCUGRAPHOPS and not LEGACY_MODE:
---> 41     raise ModuleNotFoundError(f"'{self.__class__.__name__}' requires "
     42                               f"'pylibcugraphops>=23.02'")

ModuleNotFoundError: 'CuGraphSAGEConv' requires 'pylibcugraphops>=23.02'

Environment

rusty1s commented 4 months ago

Which version of pylibcugraphops did you have installed?

puririshi98 commented 3 months ago

following up @d3netxer does your issue persist with the latest wheels or source builds or nvidia container? container: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pyg (i recommend the container for simplest and latest setup).