dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.55k stars 3.02k forks source link

`Cannot find DGL C++ graphbolt library` for torch 2.4.1 #7822

Open DanielYang59 opened 1 month ago

DanielYang59 commented 1 month ago

🐛 Bug

I believe this is a duplicate of #7247 (but for torch 2.4.1).

To Reproduce

Steps to reproduce the behavior:

>>> import dgl

Traceback (most recent call last):
  File "/Users/yang/developer/test/test_mult.py", line 1, in <module>
    import dgl
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/__init__.py", line 16, in <module>
    from . import (
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/dataloading/__init__.py", line 13, in <module>
    from .dataloader import *
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/dataloading/dataloader.py", line 27, in <module>
    from ..distributed import DistGraph
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/distributed/__init__.py", line 5, in <module>
    from .dist_graph import DistGraph, DistGraphServer, edge_split, node_split
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/distributed/dist_graph.py", line 11, in <module>
    from .. import backend as F, graphbolt as gb, heterograph_index
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/graphbolt/__init__.py", line 36, in <module>
    load_graphbolt()
  File "/Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/graphbolt/__init__.py", line 26, in load_graphbolt
    raise FileNotFoundError(
FileNotFoundError: Cannot find DGL C++ graphbolt library at /Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/graphbolt/libgraphbolt_pytorch_2.4.1.dylib

Environment

Additional context

>>> cd /Users/yang/developer/test/venv/lib/python3.12/site-packages/dgl/graphbolt
>>> ls libgraphbolt_pytorch_2.*

libgraphbolt_pytorch_2.1.0.dylib libgraphbolt_pytorch_2.2.0.dylib libgraphbolt_pytorch_2.3.0.dylib
libgraphbolt_pytorch_2.1.1.dylib libgraphbolt_pytorch_2.2.1.dylib
libgraphbolt_pytorch_2.1.2.dylib libgraphbolt_pytorch_2.2.2.dylib
Alkomnenos commented 1 month ago

Same error, have tried all combination of versions. Would appreciate a head up if someone managed to solve this :)

colintle commented 3 weeks ago

Anyone got this working yet?

ph-mehdi commented 3 weeks ago

We still have this problem in new versions, has anyone fixed this problem?

beviu commented 2 weeks ago

As a workaround, I was able to make import dgl successfully by installing older versions of PyTorch and torchdata:

$ pip install torch==2.2.1
$ pip install torchdata==0.7.1
523718 commented 2 weeks ago

In dgl website,it says:

Since 2024.06.27, we have stopped providing packages for Windows and MacOS. The latest version of available package is 2.2.1. For newer versions, please install from source.

If you have installed dgl-cudaXX.X package, please uninstall it first.

may be this can give you some ideas.

And i also met this problem,but i need to install 2.2.1version of dgl in windows 10.it seems like i should install it from source code?If anybody knows that ,please tell me how i could solve this ,thank you so much.

Alkomnenos commented 2 weeks ago

I have managed to make mine working, under the DGL package site there are several "libgraphbolt_pytorch_2.x.x.dylib" files you could find and you will know which versions of pytorch you should use. Mine issue arose from having a corrupted pytorch version registered and DGL could not properly recognize the pytorch 2.2.1 that I have installed, manually removing the corrupted pytorch files from site-packages has fixed the problem for me

DanielYang59 commented 2 weeks ago

Since 2024.06.27, we have stopped providing packages for Windows and MacOS. The latest version of available package is 2.2.1. For newer versions, please install from source.

Thanks for sharing the info.


Also I appreciate everyone's comment, however downgrading to torch==2.2.1 is not the solution to the problem.

It turns out dgl does ship pre-built binary here, but only for certain versions of torch and python, for other versions we might need to build from source.

DanielYang59 commented 2 weeks ago

I could confirm building from source following the guidance works for my Ubuntu 22.04 machine.

For a CPU-only build with torch==2.4.1, python==3.12:

git clone --recurse-submodules https://github.com/dmlc/dgl.git  && cd dgl

bash script/create_dev_conda_env.sh -c -t 2.4.1 -p 3.12  # or other versions of your choice
bash script/build_dgl.sh -c

cd python && pip install .
$ pip freeze | grep torch
torch==2.4.1+cpu
torch-geometric==2.6.1
torcheval==0.0.7
torchmetrics==1.5.1

$ pip freeze | grep dgl
dgl @ file:///home/yang/dgl/python

$ python -c "import dgl"  # no error this time

Worth noting is it takes quite some time to download & install the conda env (> 10 min) and a lot of RAM to build (~ 30 GB), make sure you have enough RAM otherwise you might see OOM errors.