ConnectionResetError: [WinError 10054] while downloading pre-trained models

The download starts fine but later on I get the following error-

Traceback (most recent call last):
  File "D:\pyai\j_v2.py", line 31, in <module>
    train_data = datasets.MNIST(root="./data", train=True, download=True, transform=transforms.ToTensor())
  File "D:\py\lib\site-packages\torchvision\datasets\mnist.py", line 99, in __init__
    self.download()
  File "D:\py\lib\site-packages\torchvision\datasets\mnist.py", line 187, in download
    download_and_extract_archive(url, download_root=self.raw_folder, filename=filename, md5=md5)
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 433, in download_and_extract_archive
    download_url(url, download_root, filename, md5)
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 151, in download_url
    raise e
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 144, in download_url
    _urlretrieve(url, fpath)
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 48, in _urlretrieve
    _save_response_content(iter(lambda: response.read(chunk_size), b""), filename, length=response.length)
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 37, in _save_response_content
    for chunk in content:
  File "D:\py\lib\site-packages\torchvision\datasets\utils.py", line 48, in <lambda>
    _save_response_content(iter(lambda: response.read(chunk_size), b""), filename, length=response.length)
  File "D:\py\lib\http\client.py", line 465, in read
    s = self.fp.read(amt)
  File "D:\py\lib\socket.py", line 705, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

any idea how to fix this

Your connection is closed so check if your firewall or any other networking setting could be responsible for it.

1 Like