snap-stanford / ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
https://ogb.stanford.edu
MIT License
1.89k stars 397 forks source link

Program cannot exit after executing the last line. (due to 'from ogb.nodeproppred import PygNodePropPreDataset') #408

Closed qiaotonggg closed 1 year ago

qiaotonggg commented 1 year ago

My code is quit simple:

import torch
import torch_geometric.transforms as T
from ogb.nodeproppred import PygNodePropPredDataset

def main():
    parser = argparse.ArgumentParser(description='OGBN-Products (GNN)')
    parser.add_argument('--device', type=int, default=1)
    args = parser.parse_args()
    print(args)
    device = f'cuda:{args.device}' if torch.cuda.is_available() else 'cpu'
    device = torch.device(device)
    print(device)
    dataset = PygNodePropPredDataset(name='ogbn-products',
                                     transform=T.ToSparseTensor())
    print('Done load.')
    data = dataset[0]
    print('Finish.')

if __name__ == "__main__":
    main()

The program cannot exit after print "Finish.", when i kill it, it will show some problems about threads

Namespace(device=1)
cuda:1
Done load.
Finish.
Exception ignored in: <module 'threading' from '/home/xxxxx/Programs/anaconda3/envs/xxxxx/lib/python3.9/threading.py'>
Traceback (most recent call last):
  File "/home/xxxxx/Programs/anaconda3/envs/profiling-cu113/lib/python3.9/threading.py", line 1477, in _shutdown
    lock.acquire()
KeyboardInterrupt:

Process finished with exit code 0
qiaotonggg commented 1 year ago

I'm sure the ogb is the latest(1.3.5), the system is Ubuntu 20.08.

qiaotonggg commented 1 year ago

When i comment from ogb.nodeproppred import PygNodePropPredDataset, it can exit with code 0 normally.

weihua916 commented 1 year ago

Hi! Hmm I cannot reproduce this. I also used ogb 1.3.5, and I was able to run your code without any issue (Ubuntu 20.04). I am a bit confused. When you comment out from ogb.nodeproppred import PygNodePropPredDataset, how did you get PygNodePropPredDataset? Also, given that the code is excuted until Finish, I am not sure if the problem is related to ogb package. Can you double-check?

qiaotonggg commented 1 year ago

Thanks for your reply. I also comment out dataset = PygNodePropPredDataset(name='ogbn-products, transform=T.ToSparseTensor()), when i comment the from ogb.nodeproppred import PygNodePropPredDataset. Moreover, when i keep from ogb.nodeproppred import PygNodePropPredDataset, and only comment the dataset = PygNodePropPredDataset(name='ogbn-products, transform=T.ToSparseTensor()), i can still wittness the problem. So, i think maybe some parallel operations in ogb cause that problem. Thank you again.

qizou97 commented 1 year ago

I had a similar problem when I tried to import PygGraphPropPredDataset from ogb.graphproppred. One way to avoid this problem is to cpoy the corresponding PygGraphPropPredDataset and and all functions and classes in ogb related to PygGraphPropPredDataset all functions and classes related to PygGraphProppredDataset cpoy to the local project, and introduce PygGraphProppredDataset from the local implementation

qiaotonggg commented 1 year ago

I had a similar problem when I tried to import PygGraphPropPredDataset from ogb.graphproppred. One way to avoid this problem is to cpoy the corresponding PygGraphPropPredDataset and and all functions and classes in ogb related to PygGraphPropPredDataset all functions and classes related to PygGraphProppredDataset cpoy to the local project, and introduce PygGraphProppredDataset from the local implementation

Thanks, it works anyway!

qiaotonggg commented 1 year ago

https://github.com/snap-stanford/ogb/issues/408#issuecomment-1499150916