Repository: snap-stanford/ogb
Issue: Importing ogb, program stuck for infinite time
Root cause: Environment Incompatibility

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
```


Note that, I am using Ubuntu. My Nvidia-smi output:


```
$ nvidia-smi
Wed Apr 20 05:09:04 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.119.03   Driver Version: 450.119.03   CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1070    Off  | 00000000:01:00.0  On |                  N/A |
| 27%   36C    P8     9W / 151W |   1227MiB /  8116MiB |      1%      Default |
|                               |                      |                  N/A
```

I am attaching torch and torch geometric version. in case it helps to debug.

```
>>> import torch as tr
>>> tr.__version__
'1.11.0'
>>> import torch_geometric as tgm
>>> tgm.__version__
'2.0.4'
>>> ogb.__version__
'1.3.3'
```

```
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Thu_Jun_11_22:26:38_PDT_2020
Cuda compilation tools, release 11.0, V11.0.194
Build cuda_11.0_bu.TC445_37.28540450_0

```

```
>>> import dgl
DGL backend not selected or invalid.  Assuming PyTorch for now.
Setting the default backend to "pytorch". You can change it in the ~/.dgl/config.json file or export the DGLBACKEND environment variable.  Valid options are: pytorch, mxnet, tensorflow (all lowercase)
d>>> dgl.__version__
'0.8.1'
>>> import rdkit
>>> rdkit.__version__
'2020.09.5'

```

Thanks for this issue. Sadly, it is super hard for me to tell where exactly the program hangs. Is it possible for you to debug this on your own (e.g., by installing OGB from source via `python setup.py develop`, and checking during which import the package is stuck)?

I try to debug a bit by my self. Whenever I try to import anything from `ogb.graphproppred` it hangs for infinite time. I double check with the requirement, and it seems like I installed the packages which should be compatible. On a different note, can you share with me the exact version of the required packages that worked for you? So I can install those and test it on my machine.

Can you give me a bit hint on what should be the proper way to debug by executing `python setup.py develop` ?

I think your versions look totally fine. Does the same error happen in case of importing `ogb.nodeproppred`? In case not, this is definitely an `rdkit` problem. You can also check where the program hangs by adding print statements after each line [here](https://github.com/snap-stanford/ogb/blob/master/ogb/graphproppred/__init__.py). For this, you need to clone OGB from GitHub and run `python setup.py develop` in the root directory.

it is really weird!

if I change the order of import then it works!



```
### importing OGB
from ogb.graphproppred import PygGraphPropPredDataset, Evaluator

import torch
from torch_geometric.loader import DataLoader
import torch.optim as optim
import torch.nn.functional as F
from torchvision import transforms
from gnn import GNN
```

instead of 
```

import torch
from torch_geometric.loader import DataLoader
import torch.optim as optim
import torch.nn.functional as F
from torchvision import transforms
from gnn import GNN


### importing OGB
from ogb.graphproppred import PygGraphPropPredDataset, Evaluator
```


do you have any explanation for that?

I think you definitely need to import `torch` first, because both PyG and DGL depend on it. Let me know if this clarifies your doubts.

I have also been getting this issue of hanging when trying to import the required packages and the stack trace when I interrupt is as follows:
```
^CTraceback (most recent call last):
  File "main.py", line 3, in <module>
    from ogb.graphproppred import PygGraphPropPredDataset, Evaluator
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/ogb/graphproppred/__init__.py", line 1, in <module>
    from .evaluate import Evaluator
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/ogb/graphproppred/evaluate.py", line 1, in <module>
    from sklearn.metrics import roc_auc_score, average_precision_score
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/sklearn/__init__.py", line 80, in <module>
    from .base import clone
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/sklearn/base.py", line 21, in <module>
    from .utils import _IS_32BIT
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 23, in <module>
    from .class_weight import compute_class_weight, compute_sample_weight
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/sklearn/utils/class_weight.py", line 7, in <module>
    from .validation import _deprecate_positional_args
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/sklearn/utils/validation.py", line 21, in <module>
    import joblib
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/joblib/__init__.py", line 113, in <module>
    from .memory import Memory, MemorizedResult, register_store_backend
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/joblib/memory.py", line 32, in <module>
    from ._store_backends import StoreBackendBase, FileSystemStoreBackend
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/joblib/_store_backends.py", line 15, in <module>
    from .backports import concurrency_safe_rename
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/joblib/backports.py", line 7, in <module>
    from distutils.version import LooseVersion
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 914, in _find_spec
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 90, in find_spec
    return method()
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 101, in spec_for_distutils
    mod = importlib.import_module('setuptools._distutils')
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/setuptools/__init__.py", line 16, in <module>
    import setuptools.version
  File "/home/dillon/anaconda3/envs/gnn/lib/python3.8/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "<frozen importlib._bootstrap>", line 202, in _lock_unlock_module
  File "<frozen importlib._bootstrap>", line 98, in acquire
KeyboardInterrupt
```
Something weird starts to happen when `sklearn.metrics` is imported but when I try to import it with an empty python file, it works fine.

Furthermore, the code seems to run fine when converted to ipynb and run with jupyter notebook.

However, what I find works for me was `pip uninstall setuptools`.


I encountered the same problem. For me, solution was downgrading the torch-geometric version. I faced the problem when I was using `torch-geometric==2.0.3`. After downgrading to `torch-geometric==1.7.0` problem was solved. Not sure how much you should go back...

 If torch-geometric is more important, try installing `ogb==1.2.1` without changing the torch-geometric version.