GATConv layer slows down code due to following warning

Could you check if a GPU version and a CPU version co-exist in your installation? That might cause problems.

If you use a conda environment, you can check with

conda list dgl

(This works as long as you are in a conda environment, even if you actually installed the packages with pip).

Otherwise, you can check with

pip freeze |grep dgl

I tried this, and all that got returned was # Name Version Build Channel dgl 0.6.0 pypi_0 pypi.

I ran the following without a warning with DGL 0.6:

import dgl
import networkx as nx
g = nx.Graph([(0, 1), (1, 2)])
gg = dgl.from_networkx(g)

Could you run the script above with -W error option so that it can treat all warnings as errors and display a traceback?

python -W error script.py

Normally in 0.6 the script above should complete without errors even with the -W error option. If your warning keeps showing up then this option should show you a traceback so we can further pinpoint where the problem is.

Hi, I ran this and no error occurred on the terminal. What does this mean with regards to where the error comes from? I usually run in PyCharm if that makes a difference.

The reason is that according to your post:

I’m making sure where the call of DGLGraph.__len__ occurs in dgl.from_networkx call by treating all warnings as errors with -W error option.

But since the error did not occur in terminal, I would suggest either
(1) running your program in terminal and see if the same warning/error would occur, or
(2) running the script in PyCharm, but with the -W error option. PyCharm should be able to specify Python flags somewhere.

My suspicion is that the reason is that the terminal and PyCharm are using two different Python environments, one of them using DGL 0.6.0 and the other using an older version.

1 Like

Thanks for the reply – I tried running from PyCharm (even the script we just used) and I get the error but not when running from terminal. I’m not sure how/why they would be running from different DGL versions; I tried opening a console within pycharm to run dgl.__version__ and it returns 0.6.0.

edit:
as an update I just ran a different file using DGL in the same project and did not receive a warning.

Just to make sure: could you try print(dgl.__version__, dgl) within the script and run the script in PyCharm (i.e. without console)? I’m not an expert of PyCharm, and my guess is that the PyCharm console may be using a different environment from PyCharm IDE.

1 Like

There seems to be some difference.

From the terminal the output is 0.6.0 <module 'dgl' from '/Users/username/opt/anaconda3/envs/misc/lib/python3.8/site-packages/dgl/__init__.py'>

and from the PyCharm console the output is 0.6.0 <module 'dgl' from '/Users/username/opt/anaconda3/envs/misc/lib/python3.8/site-packages/dgl/__init__.py'>
followed by the error /Users/username/opt/anaconda3/envs/misc/lib/python3.8/site-packages/dgl/base.py:45: DGLWarning: DGLGraph.__len__ is deprecated.Please directly call DGLGraph.number_of_nodes. return warnings.warn(message, category=category, stacklevel=1) where the error message looks like it is pointing to dgl/base.py:45 – does this seem to be the cause of the error would you say?

Did the error come with a stacktrace (only available if you run with the -W error option)?

No, I ran this in PyCharm not using the terminal in PyCharm (i.e. by just pressing the ‘play’ button). I just tried using the terminal that is within PyCharm and and I don’t get the error here. I might need post on StackOverflow as I have no idea why running it in that way from Pycharm means it points to a different location of dgl!