pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.13k stars 3.63k forks source link

Importing Graphgym Causes segmentation fault (and std::bad_alloc()) #4822

Open JohnYao93 opened 2 years ago

JohnYao93 commented 2 years ago

😵 Describe the installation problem

Hello,

I have installed the latest versions of pyg with conda as well as with pip, and trying either one separately as well, and for some reason I cannot install a version where graphgym works. I have the versions tagged below

Environment

JohnYao93 commented 2 years ago

I have the following error message: import torch_geometric.graphgym terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)

rusty1s commented 2 years ago

Thanks for reporting. Does only the import of torch_geometric.graphgym throw this error? Is it possible to debug for you which import within torch_geometric/graphgym/__init__.py causes this error exactly (e.g., via print debugging)?

JohnYao93 commented 2 years ago

Yeah it seems like there are a few places it breaks actually in the init file;

  1. at all of the following, I get the error terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped) :

from .contrib import * # noqa from .models import * # noqa from .utils import * # noqa

from .loader import create_loader from .logger import set_printing, create_logger

from .model_builder import create_model

  1. at from .train import train, I get Segmentation fault (core dumped).

I didn't keep running it after these, as I was pretty sure without half the imports the file wouldn't really run at all. But at these particular imports there were issues as stated.

JohnYao93 commented 2 years ago

After some experimentation it doesn't seem to occur elsewhere without importing graphgym. Seems like just that package is the main issue.

rusty1s commented 2 years ago

I assume this has something to do with https://github.com/pyg-team/pytorch_geometric/blob/master/torch_geometric/graphgym/contrib/act/__init__.py. What's the output of __all__ for you? Does it crash there?

JohnYao93 commented 2 years ago

You're right, there does seem something off here. I pdb'd the file as so:

from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
    basename(f)[:-3] for f in modules
    if isfile(f) and not f.endswith('__init__.py')
]
import pdb; pdb.set_trace()

and got the following: john@johns-laptop:~/Documents/pytorch_geometric/graphgym$ python -m pdb test.py /home/john/Documents/pytorch_geometric/graphgym/test.py(1)<module>() -> import torch_geometric.graphgym (Pdb) c --Return-- /home/john/.local/lib/python3.8/site-packages/torch_geometric/graphgym/contrib/act/__init__.py(8)<module>()->None -> import pdb; pdb.set_trace() (Pdb) i *** NameError: name 'i' is not defined (Pdb) print(__all__) [] Should __all__ be empty?

rusty1s commented 2 years ago

Yes, __all__ should be empty since the folder does not contain any files. I am wondering why this is not the case for you?

JohnYao93 commented 2 years ago

No as you can see in the printout it is empty. Just wondering. Must be some other issue.

rusty1s commented 2 years ago

Oh, I misread. So the issue is somewhere else? Do you know what's the variable i the error is referring to?

JohnYao93 commented 2 years ago

Ah yes that is just a typo. I was attempting to debug using interactive mode on pdb, and thought i might be the right key. Irrelevant in this case, though.

JiaxuanYou commented 2 years ago

This is a weird error I haven't encountered before. It will be great if you can pinpoint where the segmentation fault error occurs. Also, based on your description, you may want to fully uninstall your conda+pip PyG, and reinstall just one version again. Maybe it's because of cross-referencing across different installation/code bases.