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
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
I found turning off SSL verification solved this for me
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
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)