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

username: lucastononrodrigues
cooked: <p>I am getting this error when I try to download CIFAR100 and MNIST using the following line:</p>
<blockquote>
<p>train_loader = torch.utils.data.DataLoader(<br>
torchvision.datasets.CIFAR100(‘/data/’, train=True, download=True,<br>
transform=torchvision.transforms.Compose([<br>
torchvision.transforms.ToTensor(),<br>
torchvision.transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),<br>
])),<br>
batch_size=args.batch_size, shuffle=True)</p>
</blockquote>
<blockquote>
<p>train_loader = torch.utils.data.DataLoader(<br>
torchvision.datasets.MNIST(‘/data/’, train=True, download=True,<br>
transform=torchvision.transforms.Compose([<br>
torchvision.transforms.ToTensor(),<br>
torchvision.transforms.Normalize(<br>
(0.1307,), (0.3081,))<br>
])),<br>
batch_size=args.batch_size, shuffle=True)</p>
</blockquote>
<p>Have anyone had the same error?<br>
Running directly from my cpu works just fine, but in the virtual machine I get this Errno 13</p>
<p>Traceback CIFAR100</p>
<blockquote>
<p>Downloading <a href="https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz" rel="noopener nofollow ugc">https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz</a> to /data/cifar-100-python.tar.gz<br>
0it [00:00, ?it/s]Failed download. Trying https → http instead. Downloading <a href="http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz" rel="noopener nofollow ugc">http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz</a> to /data/cifar-100-python.tar.gz<br>
Traceback (most recent call last):<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 72, in download_url<br>
reporthook=gen_bar_updater()<br>
File “/home/projet21/anaconda3/lib/python3.7/urllib/request.py”, line 257, in urlretrieve<br>
tfp = open(filename, ‘wb’)<br>
PermissionError: [Errno 13] Permission denied: ‘/data/cifar-100-python.tar.gz’</p>
<p>During handling of the above exception, another exception occurred:</p>
<p>Traceback (most recent call last):<br>
File “main.py”, line 203, in <br>
main(args)<br>
File “main.py”, line 189, in main<br>
train_loader,valid_loader=build_dataset(args)<br>
File “main.py”, line 63, in build_dataset<br>
torchvision.transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/cifar.py”, line 65, in <strong>init</strong><br>
self.download()<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/cifar.py”, line 143, in download<br>
download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5)<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 256, in download_and_extract_archive<br>
download_url(url, download_root, filename, md5)<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/utils.py”, line 81, in download_url<br>
reporthook=gen_bar_updater()<br>
File “/home/projet21/anaconda3/lib/python3.7/urllib/request.py”, line 257, in urlretrieve<br>
tfp = open(filename, ‘wb’)<br>
PermissionError: [Errno 13] Permission denied: ‘/data/cifar-100-python.tar.gz’</p>
</blockquote>
<p>Traceback MNIST:</p>
<blockquote>
<p>Traceback (most recent call last):<br>
File “main.py”, line 203, in <br>
main(args)<br>
File “main.py”, line 189, in main<br>
train_loader,valid_loader=build_dataset(args)<br>
File “main.py”, line 46, in build_dataset<br>
(0.1307,), (0.3081,))<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/mnist.py”, line 79, in <strong>init</strong><br>
self.download()<br>
File “/home/projet21/anaconda3/lib/python3.7/site-packages/torchvision/datasets/mnist.py”, line 140, in download<br>
os.makedirs(self.raw_folder, exist_ok=True)<br>
File “/home/projet21/anaconda3/lib/python3.7/os.py”, line 211, in makedirs<br>
makedirs(head, exist_ok=exist_ok)<br>
File “/home/projet21/anaconda3/lib/python3.7/os.py”, line 221, in makedirs<br>
mkdir(name, mode)<br>
PermissionError: [Errno 13] Permission denied: ‘/data/MNIST’</p>
</blockquote>
<p>Thank you.</p>

username: Xiaoyu_Song
cooked: <p>I think this is due to you do not have the mkdir permission in your virtual machine. Not related to Pytorch</p>

username: lucastononrodrigues
cooked: <p>Maybe is somehow related to that, but it cannot be quite it because I do have the permission though.</p>

username: lucastononrodrigues
cooked: <p>Thank you, in the end you were right, I wasn’t using the relative path I guess. Sorry about that, quite simple.</p>