Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to import dgl 0.4.2 #1494

Closed
gcorso opened this issue May 2, 2020 · 11 comments
Closed

Impossible to import dgl 0.4.2 #1494

gcorso opened this issue May 2, 2020 · 11 comments

Comments

@gcorso
Copy link

gcorso commented May 2, 2020

I'm having this problem importing dgl 0.4.2:

DGL Version (e.g., 1.0): dgl-0.4.2
Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): pytorch 1.5.0
OS (e.g., Linux): Windows10
How you installed DGL (conda, pip, source): conda install -c dglteam dgl
Build command you used (if compiling from source):
Python version: python 3.7.6
CUDA/cuDNN version (if applicable): none
GPU models and configuration (e.g. V100): none

Traceback (most recent call last):
  File "main_molecules_graph_regression.py", line 9, in <module>
    import dgl
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\dgl\__init__.py", line 8, in <module>
    from .backend import load_backend
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\dgl\backend\__init__.py", line 48, in <module>
    load_backend(os.environ.get('DGLBACKEND', 'pytorch').lower())
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\dgl\backend\__init__.py", line 18, in load_backend
    mod = importlib.import_module('.%s' % mod_name, __name__)
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\dgl\backend\pytorch\__init__.py", line 1, in <module>
    from .tensor import *
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\dgl\backend\pytorch\tensor.py", line 5, in <module>
    import torch as th
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\site-packages\torch\__init__.py", line 81, in <module>
    ctypes.CDLL(dll)
  File "C:\Users\gabri\Python\Anaconda3\envs\benchmark_gnn2\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Impossibile trovare il modulo specificato

I am forced to use dgl 0.4.2 for the gnns benchmarks https://github.com/graphdeeplearning/benchmarking-gnns/ . Any ideas on how to solve it?

@VoVAllen
Copy link
Collaborator

VoVAllen commented May 2, 2020

Hi, Could you try uninstall and using pip install?

@gcorso
Copy link
Author

gcorso commented May 4, 2020

>>> pip install dgl==0.4.2
ERROR: Could not find a version that satisfies the requirement dgl==0.4.2 (from versions: 0.1.2, 0.1.3, 0.4.3, 0.4.3.post1)
ERROR: No matching distribution found for dgl==0.4.2

@VoVAllen
Copy link
Collaborator

VoVAllen commented May 4, 2020

cc @BarclayII
And I don't think we have any breaking change between 0.4.2 and 0.4.3. Could you try our latest version instead?

@gcorso
Copy link
Author

gcorso commented May 7, 2020

With the latest version I'm getting this error which I think is due to a change in some dgl file:

Traceback (most recent call last):
  File "project/main_molecules_graph_regression.py", line 408, in <module>
    main()
  File "project/main_molecules_graph_regression.py", line 293, in main
    dataset = LoadData(DATASET_NAME)
  File "project\data\data.py", line 24, in LoadData
    return MoleculeDataset(DATASET_NAME)
  File "project\data\molecules.py", line 149, in __init__
    f = pickle.load(f)
  File "...\Python\Anaconda3\envs\gnns\lib\site-packages\dgl\graph_index.py", line 53, in __setstate__
    num_nodes, readonly, src, dst = state
ValueError: too many values to unpack (expected 4)

@BarclayII
Copy link
Collaborator

This is very strange as pip install dgl==0.4.2 worked for me:

image

Could you uninstall dgl completely (i.e. repeatedly run pip uninstall dgl until it says the package is not installed)? Sometimes conda and pip installations will overwrite each other and mess up the package management system.

@VoVAllen
Copy link
Collaborator

VoVAllen commented May 8, 2020

And you may want to upgrade pip by python -m pip install --upgrade pip

@gcorso
Copy link
Author

gcorso commented May 8, 2020

I repeatedly run pip uninstall dgl and updated pip, however it still does not work. In your response @BarclayII I see it uses a cached file, could that be the reason why it works?

@BarclayII
Copy link
Collaborator

Removed the cache and it still worked:

image

Could it be the case that your pip is for Python 2 or Python 3.4-? Could you verify the path of your pip executable and see if it is indeed corresponding to your conda environment?

@BarclayII
Copy link
Collaborator

The latest code in master branch should be able to load pickles dumped before 0.4.2.

@ofrylivney
Copy link

With the latest version I'm getting this error which I think is due to a change in some dgl file:

Traceback (most recent call last):
  File "project/main_molecules_graph_regression.py", line 408, in <module>
    main()
  File "project/main_molecules_graph_regression.py", line 293, in main
    dataset = LoadData(DATASET_NAME)
  File "project\data\data.py", line 24, in LoadData
    return MoleculeDataset(DATASET_NAME)
  File "project\data\molecules.py", line 149, in __init__
    f = pickle.load(f)
  File "...\Python\Anaconda3\envs\gnns\lib\site-packages\dgl\graph_index.py", line 53, in __setstate__
    num_nodes, readonly, src, dst = state
ValueError: too many values to unpack (expected 4)

hi y'all, I'm getting the same error mentioned here, while trying to run the benchmarking-gnns project. using windows python 3.8.0 dgl 0.4.3. I saw that the pickle compatibility issue was fixed. what should I be installing then, to make this work?
thanks:)

@ofrylivney
Copy link

ofrylivney commented Oct 2, 2020

With the latest version I'm getting this error which I think is due to a change in some dgl file:

Traceback (most recent call last):
  File "project/main_molecules_graph_regression.py", line 408, in <module>
    main()
  File "project/main_molecules_graph_regression.py", line 293, in main
    dataset = LoadData(DATASET_NAME)
  File "project\data\data.py", line 24, in LoadData
    return MoleculeDataset(DATASET_NAME)
  File "project\data\molecules.py", line 149, in __init__
    f = pickle.load(f)
  File "...\Python\Anaconda3\envs\gnns\lib\site-packages\dgl\graph_index.py", line 53, in __setstate__
    num_nodes, readonly, src, dst = state
ValueError: too many values to unpack (expected 4)

hi y'all, I'm getting the same error mentioned here, while trying to run the benchmarking-gnns project. using windows python 3.8.0 dgl 0.4.3. I saw that the pickle compatibility issue was fixed. what should I be installing then, to make this work?
thanks:)

Just updating - I've solved this issue by looking up class GraphIndex(ObjectBase) which led to the location of the graph_index.py file on the dgl repo (https://github.com/dmlc/dgl/blob/master/python/dgl/graph_index.py) and there I saw the patch I needed to replace:

when installing 0.4.2 the setstate method of the object would look like:

def setstate(self, state):
"""The pickle state of GraphIndex is defined as a triplet
(number_of_nodes, readonly, src_nodes, dst_nodes)
"""
num_nodes, readonly, src, dst = state
self._cache = {}
self._readonly = readonly
self.init_handle_by_constructor(
_CAPI_DGLGraphCreate,
src.todgltensor(),
dst.todgltensor(),
int(num_nodes),
readonly)

And the patch is as can be seen in the following:

def __setstate__(self, state):
    """The pickle state of GraphIndex is defined as a triplet
    (number_of_nodes, readonly, src_nodes, dst_nodes)
    """
    # Pickle compatibility check
    # TODO: we should store a storage version number in later releases.
    if isinstance(state, tuple) and len(state) == 5:
        dgl_warning("The object is pickled pre-0.4.2.  Multigraph flag is ignored in 0.4.3")
        num_nodes, _, readonly, src, dst = state
    elif isinstance(state, tuple) and len(state) == 4:
        # post-0.4.3.
        num_nodes, readonly, src, dst = state
    else:
        raise IOError('Unrecognized storage format.')

    self._cache = {}
    self._readonly = readonly
    self.__init_handle_by_constructor__(
        _CAPI_DGLGraphCreate,
        src.todgltensor(),
        dst.todgltensor(),
        int(num_nodes),
        readonly)

I hope this helps anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants