question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

torchvision data downloader aborts if ipywidgets are not available

See original GitHub issue

šŸ› Bug

I am testing some PyTorch code in Deepnote and the following call to torchvision aborts since the environment doesn’t support ipywidgets

test_data = torchvision.datasets.MNIST('../data', train=False, download=True, transform=local_transforms)

To Reproduce

Check the following notebook - https://deepnote.com/project/0b12c588-a1de-4d66-bb0f-fa6b8f9b1b87

ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-c62d245b04eb> in <module>
      5 local_transforms = torchvision.transforms.Compose([local_transform_1, local_transform_2])
      6 
----> 7 test_data = torchvision.datasets.MNIST('../data', train=False, download=True, transform=local_transforms)

/shared-libs/python3.7/py/lib/python3.7/site-packages/torchvision/datasets/mnist.py in __init__(self, root, train, transform, target_transform, download)
     77 
     78         if download:
---> 79             self.download()
     80 
     81         if not self._check_exists():

/shared-libs/python3.7/py/lib/python3.7/site-packages/torchvision/datasets/mnist.py in download(self)
    144         for url, md5 in self.resources:
    145             filename = url.rpartition('/')[2]
--> 146             download_and_extract_archive(url, download_root=self.raw_folder, filename=filename, md5=md5)
    147 
    148         # process and save as torch files

/shared-libs/python3.7/py/lib/python3.7/site-packages/torchvision/datasets/utils.py in download_and_extract_archive(url, download_root, extract_root, filename, md5, remove_finished)
    254         filename = os.path.basename(url)
    255 
--> 256     download_url(url, download_root, filename, md5)
    257 
    258     archive = os.path.join(download_root, filename)

/shared-libs/python3.7/py/lib/python3.7/site-packages/torchvision/datasets/utils.py in download_url(url, root, filename, md5)
     70             urllib.request.urlretrieve(
     71                 url, fpath,
---> 72                 reporthook=gen_bar_updater()
     73             )
     74         except (urllib.error.URLError, IOError) as e:  # type: ignore[attr-defined]

/shared-libs/python3.7/py/lib/python3.7/site-packages/torchvision/datasets/utils.py in gen_bar_updater()
     13 
     14 def gen_bar_updater() -> Callable[[int, int, int], None]:
---> 15     pbar = tqdm(total=None)
     16 
     17     def bar_update(count, block_size, total_size):

/shared-libs/python3.7/py/lib/python3.7/site-packages/tqdm/notebook.py in __init__(self, *args, **kwargs)
    246         unit_scale = 1 if self.unit_scale is True else self.unit_scale or 1
    247         total = self.total * unit_scale if self.total else self.total
--> 248         self.container = self.status_printer(self.fp, total, self.desc, self.ncols)
    249         self.container.pbar = self
    250         if display_here:

/shared-libs/python3.7/py/lib/python3.7/site-packages/tqdm/notebook.py in status_printer(_, total, desc, ncols)
    113         if IProgress is None:  # #187 #451 #558 #872
    114             raise ImportError(
--> 115                 "IProgress not found. Please update jupyter and ipywidgets."
    116                 " See https://ipywidgets.readthedocs.io/en/stable"
    117                 "/user_install.html")

ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html

Expected behavior

Maybe a check can be added that skips call to tqdm if it’s not available?

cc @pmeier

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jaintj95commented, Jan 26, 2021

which version of tqdm deepnote provides ?

@vfdev-5 From my environment it seems tqdm version 4.55.1

0reactions
jaintj95commented, Feb 1, 2021

@jaintj95 a solution like tqdm/tqdm#619 (comment) should help , as it disables the tqdm bar IIUC.

If this doesn’t work, it might be because PyTorch now defaults to importing tqdm from tqdm.auto, so you might need to patch it from there

Thanks. I’ve already tried the solution you linked. It doesn’t work. Let me see if I can figure out the patch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

install ipywidgets - Read the Docs
No information is available for this page.
Read more >
How to get ipywidgets working in Jupyter Lab? - Stack Overflow
After digging into some of the libraries, I found the following: jupyter labextension install @jupyter-widgets/jupyterlab-manager is no longerĀ ...
Read more >
Interactive data visualizations - Jupyter Book
Jupyter Notebook has support for many kinds of interactive outputs, including the ipywidgets ecosystem as well as many interactive visualization libraries.
Read more >
How to use ipywidgets to make your Jupyter notebook ...
I'll show you the basics in this article of building a few simple forms to view and analyze some data. What are widgets?...
Read more >
Interactive data analysis with dropdown menu Ipywidgets and ...
Interactive data analysis with dropdown menu Ipywidgets and Plotly in Jupyter Notebook. An example of how to set up an interactive dropdown menuĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found