SSL verification error while downloading MNIST dataset
Open
@AntoineSimoulin is already working on this.
Since Aug 29, 2025.
bug
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
🐛 Describe the bug
import torch
from torch.utils.data import DataLoader
import torchvision
from torchvision import transforms, datasets
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
transform = transforms.Compose([
transforms.Resize((64,64)),
transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,))
])
train_dataset = torchvision.datasets.MNIST(
root='../../datasets',
train=True,
download=True,
transform=transform
)
RuntimeError Traceback (most recent call last)
Cell In[32], [line 16](vscode-notebook-cell:?execution_count=32&line=16)
6 ssl._create_default_https_context = ssl._create_unverified_context
10 transform = transforms.Compose([
11 transforms.Resize((64,64)),
12 transforms.ToTensor(),
13 transforms.Normalize((0.5,), (0.5,))
14 ])
---> [16](vscode-notebook-cell:?execution_count=32&line=16) train_dataset = torchvision.datasets.MNIST(
17 root='../../datasets',
18 train=True,
19 download=True,
20 transform=transform
21 )
File ~/Projects/PMLSolutions/.venv/lib/python3.13/site-packages/torchvision/datasets/mnist.py:100, in MNIST.__init__(self, root, train, transform, target_transform, download)
97 return
99 if download:
--> [100](https://file+.vscode-resource.vscode-cdn.net/Users/sujitwarrier/Projects/PMLSolutions/src/PMLSolutions/~/Projects/PMLSolutions/.venv/lib/python3.13/site-packages/torchvision/datasets/mnist.py:100) self.download()
102 if not self._check_exists():
103 raise RuntimeError("Dataset not found. You can use download=True to download it")
File ~/Projects/PMLSolutions/.venv/lib/python3.13/site-packages/torchvision/datasets/mnist.py:197, in MNIST.download(self)
195 for mirror, err in zip(self.mirrors, errors):
...
Tried https://ossci-datasets.s3.amazonaws.com/mnist/, got:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1028)>
Tried http://yann.lecun.com/exdb/mnist/, got:
HTTP Error 404: Not Found
Versions
torchvision=0.22.1
torch=2.7.1
The SSL errors are even occuring with the newer ossci links as shown.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.