[Errno 13] Permission denied: ‘/data/CIFAR100’

I am getting this error when I try to download CIFAR100 and MNIST using the following line:

train_loader = torch.utils.data.DataLoader(
torchvision.datasets.CIFAR100(’/data/’, train=True, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
])),
batch_size=args.batch_size, shuffle=True)

train_loader = torch.utils.data.DataLoader(
torchvision.datasets.MNIST(’/data/’, train=True, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(
(0.1307,), (0.3081,))
])),
batch_size=args.batch_size, shuffle=True)

Have anyone had the same error?
Running directly from my cpu works just fine, but in the virtual machine I get this Errno 13

Traceback CIFAR100

Downloading https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz to /data/cifar-100-python.tar.gz
0it [00:00, ?it/s]Failed download. Trying https → http instead. Downloading http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz to /data/cifar-100-python.tar.gz
Traceback (most recent call last):
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 72, in download_url
reporthook=gen_bar_updater()
File “/home/projet21/anaconda3/lib/python3.7/urllib/request.py”, line 257, in urlretrieve
tfp = open(filename, ‘wb’)
PermissionError: [Errno 13] Permission denied: ‘/data/cifar-100-python.tar.gz’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “main.py”, line 203, in
main(args)
File “main.py”, line 189, in main
train_loader,valid_loader=build_dataset(args)
File “main.py”, line 63, in build_dataset
torchvision.transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/cifar.py”, line 65, in init
self.download()
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/cifar.py”, line 143, in download
download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5)
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 256, in download_and_extract_archive
download_url(url, download_root, filename, md5)
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 81, in download_url
reporthook=gen_bar_updater()
File “/home/projet21/anaconda3/lib/python3.7/urllib/request.py”, line 257, in urlretrieve
tfp = open(filename, ‘wb’)
PermissionError: [Errno 13] Permission denied: ‘/data/cifar-100-python.tar.gz’

Traceback MNIST:

Traceback (most recent call last):
File “main.py”, line 203, in
main(args)
File “main.py”, line 189, in main
train_loader,valid_loader=build_dataset(args)
File “main.py”, line 46, in build_dataset
(0.1307,), (0.3081,))
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/mnist.py”, line 79, in init
self.download()
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/mnist.py”, line 140, in download
os.makedirs(self.raw_folder, exist_ok=True)
File “/home/projet21/anaconda3/lib/python3.7/os.py”, line 211, in makedirs
makedirs(head, exist_ok=exist_ok)
File “/home/projet21/anaconda3/lib/python3.7/os.py”, line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: ‘/data/MNIST’

Thank you.

I think this is due to you do not have the mkdir permission in your virtual machine. Not related to Pytorch

1 Like

Maybe is somehow related to that, but it cannot be quite it because I do have the permission though.

Thank you, in the end you were right, I wasn’t using the relative path I guess. Sorry about that, quite simple.