ImportError: cannot import name 'DILL_AVAILABLE' from 'torch.utils.data.datapipes.utils.common'

Hello, could you please help me with the error when I import dgl.Thanks !

Traceback (most recent call last):
File “”, line 1, in
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/init.py”, line 16, in
from . import (
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/dataloading/init.py”, line 13, in
from .dataloader import *
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/dataloading/dataloader.py”, line 27, in
from …distributed import DistGraph
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/distributed/init.py”, line 5, in
from .dist_graph import DistGraph, DistGraphServer, edge_split, node_split
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/distributed/dist_graph.py”, line 11, in
from … import backend as F, graphbolt as gb, heterograph_index
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/graphbolt/init.py”, line 8, in
from .base import *
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/dgl/graphbolt/base.py”, line 8, in
from torchdata.datapipes.iter import IterDataPipe
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/torchdata/init.py”, line 9, in
from . import datapipes
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/torchdata/datapipes/init.py”, line 9, in
from . import iter, map, utils
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/torchdata/datapipes/iter/init.py”, line 79, in
from torchdata.datapipes.iter.util.cacheholder import (
File “/data/liuxin/anaconda3/lib/python3.11/site-packages/torchdata/datapipes/iter/util/cacheholder.py”, line 24, in
from torch.utils.data.datapipes.utils.common import _check_unpickable_fn, DILL_AVAILABLE
ImportError: cannot import name ‘DILL_AVAILABLE’ from ‘torch.utils.data.datapipes.utils.common’ (/data/liuxin/anaconda3/lib/python3.11/site-packages/torch/utils/data/datapipes/utils/common.py)

OS: Ubuntu 20.04.2 LTS
Python version: 3.11.7
Cuda version:12.0
Torch versin: pytorch-cuda=12.1
DGL version: cu121
Installation: Conda

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
conda install -c dglteam/label/cu121 dgl

My cuda is 12.0. But PyTorch and DGL does not provide it. So I installed them with cuda12.1.

I could run training using GPU with torch but fail to import dgl. :joy:

Seems to be related: Restore DILL_AVAILABLE for backwards compat with torchdata by ezyang · Pull Request #122616 · pytorch/pytorch · GitHub

Thanks so much!
Later I tried another environment with Python 3.10 and cuda 12.1. And there is no error when importing DGL. But thank you any way!!!

Hello,
I am running my code on a server with:
Operating system: Linux i9 5.19.0-38-generic #39~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 17 21:16:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Python: Python 3.10.12
Pytorch: pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118

and this is what I get:

Traceback (most recent call last):
File “/home/artemis/tfbs_notebooks_multi4/all_tfs_3layer_multi.py”, line 75, in
train_loader = pickle.load(f)
File “/home/artemis/tfbs_notebooks_multi4/stream_data.py”, line 7, in
import torchdata.datapipes as dp
File “/home/artemis/.local/lib/python3.10/site-packages/torchdata/init.py”, line 9, in
from . import datapipes
File “/home/artemis/.local/lib/python3.10/site-packages/torchdata/datapipes/init.py”, line 9, in
from . import iter, map, utils
File “/home/artemis/.local/lib/python3.10/site-packages/torchdata/datapipes/iter/init.py”, line 79, in
from torchdata.datapipes.iter.util.cacheholder import (
File “/home/artemis/.local/lib/python3.10/site-packages/torchdata/datapipes/iter/util/cacheholder.py”, line 24, in
from torch.utils.data.datapipes.utils.common import _check_unpickable_fn, DILL_AVAILABLE
ImportError: cannot import name ‘DILL_AVAILABLE’ from ‘torch.utils.data.datapipes.utils.common’ (/home/artemis/.local/lib/python3.10/site-packages/torch/utils/data/datapipes/utils/common.py)

Which version of DGL did you try to install ?

I also had the same problem with DGL 2.1 which was due to a mismatch with the torch version. After updating it to DGL 2.2.1 for torch 2.3 with cuda 11.8 I don’t get the error anymore.

We have fixed this in our latest release 2.2.1, please refer to it, thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.