pytorch / pytorch/vision

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)

Open
#5,311 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

windows
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🐛 Describe the bug

When downloading weights data from the PyTorch hub we get the following:

[stdlog] 2022-01-27 14:41:18,434 client           L0864 INFO | Traceback (most recent call last):
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\site-packages\torchvision\models\detection\faster_rcnn.py", line 369, in fasterrcnn_resnet50_fpn
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |     state_dict = load_state_dict_from_url(model_urls['fasterrcnn_resnet50_fpn_coco'],
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\site-packages\torch\hub.py", line 524, in load_state_dict_from_url
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |     download_url_to_file(url, cached_file, hash_prefix, progress=progress)
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\site-packages\torch\hub.py", line 394, in download_url_to_file
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |     u = urlopen(req)
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 214, in urlopen
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |     return opener.open(url, data, timeout)
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 517, in open
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |     response = self._open(req, data)
[stdlog] 2022-01-27 14:41:18,435 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 534, in _open
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |     result = self._call_chain(self.handle_open, protocol, protocol +
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 494, in _call_chain
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |     result = func(*args)
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 1385, in https_open
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |     return self.do_open(http.client.HTTPSConnection, req,
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |   File "C:\Program Files\Python39\lib\urllib\request.py", line 1345, in do_open
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO |     raise URLError(err)
[stdlog] 2022-01-27 14:41:18,436 client           L0864 INFO | urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)>

whereby checks of the certificate validity passed and this issue only happens on Windows (tested the same code on Linux without any problem). Downloading the same data file from a browser works fine (don't mind the loaded page, I loaded download.pytorch.org at first):

image

Versions

C:>python.exe collect_env.py
Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.
It can be downloaded at https://aka.ms/vs/16/release/vc_redist.x64.exe
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Enterprise 2016 LTSB
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.14393-SP0
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] Could not collect
[conda] Could not collect

cc @peterjc123 @nbcsm @guyang3532 @maxluk @gunandrose4u @mszhanyi

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Windows failure through torchvision.models.detection.fasterrcnn_resnet50_fpn and trace the download path through torch.hub.load_state_dict_from_url and download_url_to_file. Compare this with the successful browser download and verify that the completed behavior preserves certificate validation while allowing the model weights to download on the reported Windows environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.