Skip to content

random_walk_cuda is causing an illegal memory access #176

Open
@ProfDoof

Description

@ProfDoof

Hi,

When running the following code, I get an illegal memory access error with the following graph. I am not sure why and do not understand the algorithm or C++ well enough to track it down. I do not get the error when I set device to 'cpu'.

I'm using the nightly build of pyg installed through a locally built conda package, and version 1.6.1 of PyTorch-cluster.

from torch_geometric.data import Data
from torch_geometric.utils import to_networkx
from networkx.drawing.nx_agraph import write_dot
import torch
new_node_ids = [x for x in range(7)]
sources = [
    0, 1, 2, 2, 4, 5,
]

targets = [
    1, 2, 3, 4, 5, 2,
]

data = Data(torch.tensor(new_node_ids), torch.tensor([sources, targets]))
data.num_nodes = 7

write_dot(to_networkx(data), 'test_test.dot')

device = 'cuda'
rowptr, col, perm = data.to(device).csr()
rowptr, col = rowptr[None], col[None]

print(rowptr, col)
start_indices = torch.arange(0, data.num_nodes, dtype=torch.long).flatten().to(device)

print(torch.ops.torch_cluster.random_walk(rowptr, col, start_indices,
                                 10, 2, 4))

EDIT:

Here's the error I get

tensor([0, 1, 2, 4, 4, 5, 6, 6], device='cuda:0') tensor([1, 2, 3, 4, 5, 2], device='cuda:0')
Traceback (most recent call last):
  File "/home/john/Research/EmbeddingGraphs/cfg2vec/gnn/test.py", line 25, in <module>
    print(torch.ops.torch_cluster.random_walk(rowptr, col, start_indices,
  File "/home/john/mambaforge/envs/gnn/lib/python3.9/site-packages/torch/_ops.py", line 503, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: CUDA error: an illegal memory access was encountered
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions