IOError: [Errno 121] Remote I/O error

Hi guys,

I have been receiving the following errors when loading images with PIL.Image and could not find ways to solve them. Could anyone help me?

 for i, inputs in enumerate(data_loader):
  File "/homes/.local/lib/python2.7/site-packages/torch/utils/data/", line 210, in __next__
    return self._process_next_batch(batch)
  File "/homes/.local/lib/python2.7/site-packages/torch/utils/data/", line 230, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
IOError: Traceback (most recent call last):
  File "/homes/.local/lib/python2.7/site-packages/torch/utils/data/", line 42, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/homes/my-project/utils/data/", line 23, in __getitem__
    return self._get_single_item(indices)
  File "/homes/my-project/utils/data/", line 30, in _get_single_item
    img ='RGB')
  File "/homes/.local/lib/python2.7/site-packages/PIL/", line 2530, in open
    fp =, "rb")
IOError: [Errno 121] Remote I/O error: '/homes/my-project/images/571_02_0001.jpg'

The _get_single_item function in looks like:

def _get_single_item(self, index):
        fpath, others = self.dataset[index]
        img ='RGB')
        if self.transform is not None:
            img = self.transform(img)
        return img

I am sure there is no problem with those images that cause the errors, because I tried opening those images that caused the errors in an independent console and they can be successfully opened.

it’s possible that the files are not accessible intermittently, or under heavy use of the I/O system.

In the terminal when you access them once, it’s possible that you dont see this error…

1 Like

I am also getting the same error every time I train a pytorch model. Is there any solution for this problem?

1 Like