Repository: pytorch
Issue: CI: Flaky download from download.pytorch.org
Labels: module: ci,triaged,module: flaky-tests,better-engineering

Downloads from download.pytorch.org sometimes fail. Sample:

```
Dec 03 07:21:59 Downloading: \"https://download.pytorch.org/models/resnet18-5c106cde.pth\" to /var/lib/jenkins/.torch/models/resnet18-5c106cde.pth
Dec 03 07:21:59 ERROR
Dec 03 07:21:59 test_check_onnx_broadcast (__main__.TestONNXUtils) ... ok
Dec 03 07:21:59 test_prepare_onnx_paddings (__main__.TestONNXUtils) ... ok
Dec 03 07:21:59 
Dec 03 07:21:59 ======================================================================
Dec 03 07:21:59 ERROR: setUpClass (__main__.TestHub)
Dec 03 07:21:59 ----------------------------------------------------------------------
Dec 03 07:21:59 Traceback (most recent call last):
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connection.py\", line 171, in _new_conn
Dec 03 07:21:59     (self._dns_host, self.port), self.timeout, **extra_kw)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py\", line 56, in create_connection
Dec 03 07:21:59     for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/socket.py\", line 745, in getaddrinfo
Dec 03 07:21:59     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
Dec 03 07:21:59 socket.gaierror: [Errno -3] Temporary failure in name resolution
Dec 03 07:21:59 
Dec 03 07:21:59 During handling of the above exception, another exception occurred:
Dec 03 07:21:59 
Dec 03 07:21:59 Traceback (most recent call last):
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py\", line 600, in urlopen
Dec 03 07:21:59     chunked=chunked)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py\", line 343, in _make_request
Dec 03 07:21:59     self._validate_conn(conn)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py\", line 849, in _validate_conn
Dec 03 07:21:59     conn.connect()
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connection.py\", line 314, in connect
Dec 03 07:21:59     conn = self._new_conn()
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connection.py\", line 180, in _new_conn
Dec 03 07:21:59     self, \"Failed to establish a new connection: %s\" % e)
Dec 03 07:21:59 urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fa6a8042080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
Dec 03 07:21:59 
Dec 03 07:21:59 During handling of the above exception, another exception occurred:
Dec 03 07:21:59 
Dec 03 07:21:59 Traceback (most recent call last):
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/adapters.py\", line 445, in send
Dec 03 07:21:59     timeout=timeout
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py\", line 638, in urlopen
Dec 03 07:21:59     _stacktrace=sys.exc_info()[2])
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/urllib3/util/retry.py\", line 398, in increment
Dec 03 07:21:59     raise MaxRetryError(_pool, url, error or ResponseError(cause))
Dec 03 07:21:59 urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Max retries exceeded with url: /models/resnet18-5c106cde.pth (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa6a8042080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Dec 03 07:21:59 
Dec 03 07:21:59 During handling of the above exception, another exception occurred:
Dec 03 07:21:59 
Dec 03 07:21:59 Traceback (most recent call last):
Dec 03 07:21:59   File \"test_utils.py\", line 449, in setUpClass
Dec 03 07:21:59     cls.resnet18_pretrained = models.__dict__['resnet18'](pretrained=True).state_dict()
Dec 03 07:21:59   File \"/var/lib/jenkins/.local/lib/python3.6/site-packages/torchvision/models/resnet.py\", line 165, in resnet18
Dec 03 07:21:59     model.load_state_dict(model_zoo.load_url(model_urls['resnet18']))
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/torch/utils/model_zoo.py\", line 66, in load_url
Dec 03 07:21:59     _download_url_to_file(url, cached_file, hash_prefix, progress=progress)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/torch/utils/model_zoo.py\", line 72, in _download_url_to_file
Dec 03 07:21:59     u = urlopen(url, stream=True)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/api.py\", line 72, in get
Dec 03 07:21:59     return request('get', url, params=params, **kwargs)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/api.py\", line 58, in request
Dec 03 07:21:59     return session.request(method=method, url=url, **kwargs)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/sessions.py\", line 512, in request
Dec 03 07:21:59     resp = self.send(prep, **send_kwargs)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/sessions.py\", line 622, in send
Dec 03 07:21:59     r = adapter.send(request, **kwargs)
Dec 03 07:21:59   File \"/opt/conda/lib/python3.6/site-packages/requests/adapters.py\", line 513, in send
Dec 03 07:21:59     raise ConnectionError(e, request=request)
Dec 03 07:21:59 requests.exceptions.ConnectionError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Max retries exceeded with url: /models/resnet18-5c106cde.pth (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa6a8042080>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Dec 03 07:21:59 
Dec 03 07:21:59 ----------------------------------------------------------------------
Dec 03 07:21:59 Ran 16 tests in 29.709s
Dec 03 07:21:59 
Dec 03 07:21:59 FAILED (errors=1, skipped=3)
Dec 03 07:21:59 Traceback (most recent call last):
Dec 03 07:21:59   File \"test/run_test.py\", line 431, in <module>
Dec 03 07:21:59     main()
Dec 03 07:21:59   File \"test/run_test.py\", line 423, in main
Dec 03 07:21:59     raise RuntimeError(message)
Dec 03 07:21:59 RuntimeError: test_utils failed!
```

Log: https://circleci.com/gh/pytorch/pytorch/347714?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link