text
text copied to clipboard
NameError: name 'IterableWrapper' is not defined in WikiText2
Hi,
When I tried loading wikipedia data using torchtext.dataset
the error occured.
from torchtext.datasets import WikiText2
train_iter = WikiText2(split='train')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [5], in <cell line: 2>()
1 from torchtext.datasets import WikiText2
----> 2 train_iter = WikiText2(split='train')
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/torchtext/data/datasets_utils.py:193, in _create_dataset_directory.<locals>.decorator.<locals>.wrapper(root, *args, **kwargs)
191 if not os.path.exists(new_root):
192 os.makedirs(new_root, exist_ok=True)
--> 193 return fn(root=new_root, *args, **kwargs)
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/torchtext/data/datasets_utils.py:155, in _wrap_split_argument_with_fn.<locals>.new_fn(root, split, **kwargs)
153 result = []
154 for item in _check_default_set(split, splits, fn.__name__):
--> 155 result.append(fn(root, item, **kwargs))
156 return _wrap_datasets(tuple(result), split)
File /anaconda/envs/azureml_py38/lib/python3.8/site-packages/torchtext/datasets/wikitext2.py:77, in WikiText2(root, split)
72 if not is_module_available("torchdata"):
73 raise ModuleNotFoundError(
74 "Package `torchdata` not found. Please install following instructions at https://github.com/pytorch/data"
75 )
---> 77 url_dp = IterableWrapper([URL])
78 # cache data on-disk
79 cache_compressed_dp = url_dp.on_disk_cache(
80 filepath_fn=partial(_filepath_fn, root),
81 hash_dict={_filepath_fn(root): MD5},
82 hash_type="md5",
83 )
NameError: name 'IterableWrapper' is not defined
Environment
I excuted this code on this enviroment.
GPU
Tesla K80
NVIDIA-SMI 470.129.06 Driver Version: 470.129.06 CUDA Version: 11.4
- python=3.8.5
pytorch-transformers==1.0.0
torch==1.12.0
torch-tb-profiler==0.4.0
torchdata==0.4.0
torchtext==0.13.0
torchvision==0.9.1
This is a duplicate of #1744. Let me see if I can repro this.
This error is quite strange. It should give error here when we fist try to import it (assuming torchdata is installed which is the case?)
This is super weird and can't reproduce on torchdata side.
@yushikmr Could you try to run
import torchdata
from torchdata.datapipes.iter import IterableWrapper
in your environment to see if any Error is raised.
I have the same error. Trying:
import torchdata
from torchdata.datapipes.iter import IterableWrapper could not solve it either.
Please keep me posted if you find a workaround.
Closing as https://github.com/pytorch/text/issues/1744 has now been resolved