TianxiangZhao / GraphSmote

Pytorch implementation of paper 'GraphSMOTE: Imbalanced Node Classification on Graphs with Graph Neural Networks' to appear on WSDM2021
150 stars 29 forks source link

Solution for CUDA error #5

Open Lucienxhh opened 2 years ago

Lucienxhh commented 2 years ago

If you want to train model on CUDA, modify these lines as follows:

{
    "Modification1":
    {
        "file": "models.py",
        "lines": [193],
        "origin": "if not isinstance(adj, torch.sparse.FloatTensor): ",
        "new": "if adj.layout != torch.sparse_coo:"
    },
    "Modification2":
    {
        "file": "utils.py",
        "lines": [275, 294, 349],
        "origin": "distance = squareform(pdist(chosen_embed.detach()))",
        "new": "distance = squareform(pdist(chosen_embed.cpu().detach()))"
    },
}

Though there are still some lines reporting errors, modify them referring to Modification2 (i.e., xx.detach() => xx.cpu().detach())

@TianxiangZhao Please check it if convenient. if correct, a modification sounds good.

TianxiangZhao commented 2 years ago

Thanks!@Lucienxhh

godlovxiari commented 1 year ago

When I modified according to the suggestions, I encountered new problems: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 How to solve this problem? thank you.