I made a GNN with DGL, but when I move my model and data to the GPU, I get a DGL warning that says
/usr/local/lib/python3.7/site-packages/dgl/base.py:45: DGLWarning: The input graph for the user-defined edge function does not contain valid edges
return warnings.warn(message, category=category, stacklevel=1)
And an error that says:
RuntimeError: CUDA error: invalid configuration argument
I think the source of the problem is this model I use as my DGL message_func:
class MessageFunc(torch.nn.Module):
def __init__(self, embed_size, hidden_size):
super().__init__()
self.rnn = torch.nn.LSTM(embed_size * 2, hidden_size)
def forward(self, edges):
node_reps, edge_reps = edges.src["rep"], edges.data["rep"]
inputs = torch.cat([node_reps, edge_reps], 1)
inputs = inputs.unsqueeze(0)
rnn_state = edges.src["sum_incoming_state"]
hiddens, cells = rnn_state[:, 0].contiguous(), rnn_state[:, 1].contiguous()
hiddens, cells = hiddens.unsqueeze(0), cells.unsqueeze(0)
outputs, (new_hiddens, new_cells) = self.rnn(inputs, (hiddens, cells))
new_hiddens, new_cells = new_hiddens.squeeze(0), new_cells.squeeze(0)
new_rnn_state = torch.stack([new_hiddens, new_cells], 1)
new_data = { "state": new_rnn_state }
return new_data
What could I be doing wrong and how can I fix it?