text: NameError: name 'IterableWrapper' is not defined

🐛 Bug

Hello, I am trying to load torchtext datasets to reproduce a couple of the tutorials using the new PyTorch MPS support on Mac. After downloading torchdata I get the following error when trying to load any of the datasets in torchtext.datasets:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Input In [51], in <cell line: 1>()
----> 1 data = torchtext.datasets.IMDB(
      2     '~/data',
      3     split='train'
      4 )

File ~/opt/anaconda3/envs/main/lib/python3.10/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 ~/opt/anaconda3/envs/main/lib/python3.10/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 ~/opt/anaconda3/envs/main/lib/python3.10/site-packages/torchtext/datasets/imdb.py:86, in IMDB(root, split)
     81 if not is_module_available("torchdata"):
     82     raise ModuleNotFoundError(
     83         "Package `torchdata` not found. Please install following instructions at `https://github.com/pytorch/data`"
     84     )
---> 86 url_dp = IterableWrapper([URL])
     88 cache_compressed_dp = url_dp.on_disk_cache(
     89     filepath_fn=partial(_filepath_fn, root),
     90     hash_dict={_filepath_fn(root): MD5},
     91     hash_type="md5",
     92 )
     93 cache_compressed_dp = HttpReader(cache_compressed_dp).end_caching(mode="wb", same_filepath_fn=True)

NameError: name 'IterableWrapper' is not defined

My environment screen dump is below. Thanks.

Collecting environment information...
PyTorch version: 1.13.0.dev20220525
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.3.1 (x86_64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2.5)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.4 (main, Mar 31 2022, 03:38:35) [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-10.16-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.22.4
[pip3] torch==1.13.0.dev20220525
[pip3] torchaudio==0.12.0.dev20220525
[pip3] torchdata==0.5.0.dev20220525
[pip3] torchtext==0.13.0.dev20220525
[pip3] torchvision==0.14.0.dev20220525
[conda] numpy                     1.22.4                   pypi_0    pypi
[conda] torch                     1.13.0.dev20220525          pypi_0    pypi
[conda] torchaudio                0.12.0.dev20220525          pypi_0    pypi
[conda] torchdata                 0.5.0.dev20220525          pypi_0    pypi
[conda] torchtext                 0.13.0.dev20220525          pypi_0    pypi
[conda] torchvision               0.14.0.dev20220525          pypi_0    pypi

torchtext version is  0.13.0.dev20220525

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 15 (7 by maintainers)

Most upvoted comments

You shoud install torchdata, then restart and import torchdata. It worked for me.

I am closing this Issue because TorchData currently provides pre-assembled binaries for Mac M1 on PyPI and Conda after 0.4.1

You should be able to install torchdata == 0.4.1 and torchtext == 0.13.1 via

  • pip3 install torch torchdata torchtext
  • conda install pytorch torchdata torchtext -c pytorch

So, this issue should be resolved for Mac M1.

I found the solution in operating on colab.

You should rerun your notebook as below:

!pip install torchdata
exit()

and re-turn on your runtime and:

import torchtext
import torchdata

Then, your task will be working on well.

@rkingery let me know if @MadSleep’s suggestion helps fix your issue. Will close out this issue if it does.