Skip to content

[BUG] - Dependency Issue in Language Modeling with nn.Transformer and torchtext Tutorial #2895

Closed
@jamesdhope

Description

@jamesdhope

Issue and Suggested Fix

Please can this helpful tutorial be updated with the HF from datasets import load_dataset and merged into main with the dependency issue workaround:

import torch
torch.utils.data.datapipes.utils.common.DILL_AVAILABLE = torch.utils._import_utils.dill_available()
import torchdata

Asset

https://colab.research.google.com/github/pytorch/tutorials/blob/gh-pages/_downloads/9cf2d4ead514e661e20d2070c9bf7324/transformer_tutorial.ipynb#scrollTo=TY5T9Gic_qih

Describe the bug

ImportError                               Traceback (most recent call last)
[<ipython-input-26-b02c7921f3b1>](https://localhost:8080/#) in <cell line: 5>()
      3 from torchtext.vocab import build_vocab_from_iterator
      4 
----> 5 train_iter = WikiText2(split='train')
      6 tokenizer = get_tokenizer('basic_english')
      7 vocab = build_vocab_from_iterator(map(tokenizer, train_iter), specials=['<unk>'])

6 frames
[/usr/local/lib/python3.10/dist-packages/torchdata/datapipes/iter/util/cacheholder.py](https://localhost:8080/#) in <module>
     22     portalocker = None
     23 
---> 24 from torch.utils.data.datapipes.utils.common import _check_unpickable_fn, DILL_AVAILABLE
     25 
     26 from torch.utils.data.graph import traverse_dps

ImportError: cannot import name 'DILL_AVAILABLE' from 'torch.utils.data.datapipes.utils.common' (/usr/local/lib/python3.10/dist-packages/torch/utils/data/datapipes/utils/common.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Describe your environment

Google Colab environment. Have replicated the issue locally with same pip package versions.

cc @sekyondaMeta @svekars @kit1980

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions