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

Import issue in ogb #289

Closed Zahra-Bakhtiari closed 2 years ago

Zahra-Bakhtiari commented 2 years ago

The ogb package can not be imported on console now and will generate errors for the below imports:

import torch import ogb from ogb.graphproppred import GraphPropPredDataset from ogb.graphproppred import PygGraphPropPredDataset

In addition log generation is not implemented in init files. I also noticed that the lines in init that blocks proper import have not yet been used anywhere else in the program so I have a PR to address these issues.

https://github.com/Zahra-Bakhtiari/GraphPropPred_bug_fix/pull/1/files

I also did some google search and noticed that this is a big struggle for the new ogb users, several open issues exist on it :)

weihua916 commented 2 years ago

Hi! Thanks for the PR! Could you elaborate on what is the import error? I think people just need to install some prerequisites (torch, rdkit, torch-geometric, dgl) before using ogb. I try to print fewer errors because some package is not necessary for some users (dgl is not necessary for PyG users, rdkit is not necessary for non-molecule graph datasets)

Zahra-Bakhtiari commented 2 years ago

Without logs users are getting just below error: image

Zahra-Bakhtiari commented 2 years ago

with the changes in this PR import is successful for both: image

Zahra-Bakhtiari commented 2 years ago

these 2 lines are causing import issues:

from torch_geometric.data import InMemoryDataset noqa pylint: disable from ogb.io.read_graph_pyg import read_graph_pyg

it looks like InMemoryDataset is not actively being used anywhere in the file so it can get converted to object.

In addition the below line in init also causes import issue:

TODO: The below line causes import issue for "from ogb.graphproppred import PygGraphPropPredDataset" and is not being used anywhere else self.data, self.slices = torch.load(self.processed_paths[0])

weihua916 commented 2 years ago

Did you install torch-geometric? In order to use PyGGraphPropDataset, you need to have pyg.

Zahra-Bakhtiari commented 2 years ago

yes, this is the screenshot of my virtualenv:

image

weihua916 commented 2 years ago

can you successfully do the following?

from torch_geometric.data import InMemoryDataset

It's likely that your torch_geometric is not installed properly.

Zahra-Bakhtiari commented 2 years ago

image

Zahra-Bakhtiari commented 2 years ago

the installation looks fine but the import provides this error: image

weihua916 commented 2 years ago

I see. You need to install torch_sparse correctly. See https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html

faysalhossain2007 commented 2 years ago

Hi I am able to run from torch_geometric.data import InMemoryDataset successfully. But whenever I try to import anything from ogb, the program stuck for infinite time. Import code is: from ogb.graphproppred import Evaluator

I followed the following command to install torch in conda environment:

CUDA=cu113
TORCH=1.11.0
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric
rusty1s commented 2 years ago

Please see my reply in https://github.com/snap-stanford/ogb/issues/322#issuecomment-1104761589.

Prasanth-Dwadasi commented 1 year ago

Did you find any solution for this issue? I'm facing the same issue while importing from ogb.graphproppred. It's taking infinite time to import

Qitong-Wang commented 1 year ago

Did you find any solution for this issue? I'm facing the same issue while importing from ogb.graphproppred. It's taking infinite time to import

I fix this problem by calling import sklearn at first, sinceogb.graphproppred.evaluate.pycallsfrom sklearn.metrics import ...In my case, it is an issue with sklearn.

HxyScotthuang commented 10 months ago

Import sklearn before also solve my problem. Thanks! @Qitong-Wang !