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.

Trying to CIFAR-10 from torchvision.datasets and receiving URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)>

See original GitHub issue

🐛 Bug

Trying to download CIFAR-10 from torchvision.datasets and receiving URLError:<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)> when downloading Download fails

To Reproduce

Steps to reproduce the behavior:

dataset = torchvision.datasets.CIFAR10(root='dataset/',train=True,transform=transform,download=True)

Expected behavior

Pre-trained models should be downloaded without certificate failures

Environment

PyTorch version: 1.9.1+cu111 Is debug build: False CUDA used to build PyTorch: 11.1 ROCM used to build PyTorch: N/A

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

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] (64-bit runtime) Python platform: Windows-10-10.0.19044-SP0 Is CUDA available: True CUDA runtime version: 11.2.67

GPU models and configuration: GPU 0: NVIDIA GeForce GT 1030 Nvidia driver version: 465.89 cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\cudnn_ops_train64_8.dll HIP runtime version: N/A MIOpen runtime version: N/A

Versions of relevant libraries: [pip3] numpy==1.19.5

[pip3] pytorch-lightning==1.5.1

[pip3] torch==1.9.1+cu111

[pip3] torch-tb-profiler==0.2.1

[pip3] torchaudio==0.9.1

[pip3] torchmetrics==0.6.0

[pip3] torchvision==0.10.1+cu111

cc @pmeier @YosuaMichael @fmassa @vfdev-5

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

26reactions
BenjaminPoolecommented, Dec 6, 2021

I found turning off SSL verification solved this for me

import ssl ssl._create_default_https_context = ssl._create_unverified_context

0reactions
dstkibbromcommented, Nov 10, 2022

I have been getting similar error but fixed it with the recommendation from @pmeier, but instead of adding the ssl script like he suggested, editing the Pytorch library url has worked for me. In the library the url has a value of “https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz”. To bypass the error we just have to change the url to one with out the ssl, http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz. To do this:

torchvision.datasets.CIFAR10.url="http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz"

then the torch vision data download should work fine without error.

all_images = torchvision.datasets.CIFAR10(train=True, root="data",download=True)

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSLCertVerificationError when downloading pytorch datasets ...
I am having trouble downloading the CIFAR-10 dataset from pytorch. Mostly it seems like some SSL error which I don't really know how...
Read more >
Certificate has expired - TorchStudio Forum
URLError : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)". I am using Windows 10.
Read more >
How to fix Python SSL CERTIFICATE_VERIFY_FAILED
As a quick (and insecure) fix, you can turn certificate verification off, by: Set PYTHONHTTPSVERIFY environment variable to 0. For example, run. export ......
Read more >
SSL: CERTIFICATE_VERIFY_FAILED Error in Python (2022)
How to fix: SSL : CERTIFICATE_VERIFY_FAILED Error in Python (2022) ... this command: /Applications/Python\ 3.9/Install\ Certificates.command ...
Read more >
CERTIFICATE_VERIFY_FAILED] certificate verify failedが出る ...
以下を参考にしました。 Trying to CIFAR-10 from torchvision.datasets and receiving URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] ...
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