the-full-stack / fsdl-text-recognizer-2021-labs

Complete deep learning project developed in Full Stack Deep Learning, Spring 2021
https://bit.ly/berkeleyfsdl
MIT License
452 stars 281 forks source link

HTTP Error 403 Lab1 #14

Closed forrestmckee closed 3 years ago

forrestmckee commented 3 years ago

I'm attempting to follow along the Lab 1 lecture using Google Colab.

Unfortunately, I'm getting a 403 error when I get to the point of running the first script.

My colab session has a P100 and is running Python 3.7.10

Complete Error Message:

/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py:49: UserWarning: You have set progress_bar_refresh_rate < 20 on Google Colab. This may crash. Consider using progress_bar_refresh_rate >= 20 in Trainer.
  warnings.warn(*args, **kwargs)
GPU available: True, used: False
TPU available: None, using: 0 TPU cores
/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py:49: UserWarning: GPU available but not used. Set the --gpus flag when calling the script.
  warnings.warn(*args, **kwargs)
Using downloaded and verified file: /content/fsdl-text-recognizer-2021-labs/data/downloaded/MNIST/raw/train-images-idx3-ubyte.gz
Extracting /content/fsdl-text-recognizer-2021-labs/data/downloaded/MNIST/raw/train-images-idx3-ubyte.gz to /content/fsdl-text-recognizer-2021-labs/data/downloaded/MNIST/raw
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to /content/fsdl-text-recognizer-2021-labs/data/downloaded/MNIST/raw/train-labels-idx1-ubyte.gz
0it [00:00, ?it/s]Traceback (most recent call last):
  File "training/run_experiment.py", line 96, in <module>
    main()
  File "training/run_experiment.py", line 89, in main
    trainer.tune(lit_model, datamodule=data)  # If passing --auto_lr_find, this will set learning rate
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 851, in tune
    self.tuner.tune(model, train_dataloader, val_dataloaders, datamodule)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/tuner/tuning.py", line 40, in tune
    self.trainer.data_connector.prepare_data(model)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/connectors/data_connector.py", line 59, in prepare_data
    self.trainer.datamodule.prepare_data()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/core/datamodule.py", line 92, in wrapped_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py", line 39, in wrapped_fn
    return fn(*args, **kwargs)
  File "/content/fsdl-text-recognizer-2021-labs/lab1/text_recognizer/data/mnist.py", line 29, in prepare_data
    TorchMNIST(self.data_dir, train=True, download=True)
  File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/mnist.py", line 79, in __init__
    self.download()
  File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/mnist.py", line 146, in download
    download_and_extract_archive(url, download_root=self.raw_folder, filename=filename, md5=md5)
  File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/utils.py", line 256, in download_and_extract_archive
    download_url(url, download_root, filename, md5)
  File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/utils.py", line 84, in download_url
    raise e
  File "/usr/local/lib/python3.7/dist-packages/torchvision/datasets/utils.py", line 72, in download_url
    reporthook=gen_bar_updater()
  File "/usr/lib/python3.7/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
0it [00:00, ?it/s]
impiyush commented 3 years ago

This is a known issue in torchvision which occurs due to web host change of yann lecun website where the MNIST data is being pulled from. This will be fixed in the next release of torchvision but in the meantime you can follow the solution posted on this issue's github : https://github.com/pytorch/vision/issues/3497

forrestmckee commented 3 years ago

@impiyush I jumped the gun on closing this issue. I didn't have a chance to try the solution until now. Based on the commentary, I assumed it would work. Unfortunately, running

from six.moves import urllib
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(opener)

Still resulted in the same error.