OSError on Colab

Ben_Ogie: <p>I keep getting this error on google colab after training for some epochs using pytorch 0.4.1.</p>
<pre><code class="lang-auto">---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
&lt;ipython-input-5-c9e4acd77c1d&gt; in &lt;module&gt;()
     14   # Train
     15 
---&gt; 16   for data, label in train_dataloader:
     17 
     18     if torch.cuda.is_available():

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __next__(self)
    334                 self.reorder_dict[idx] = batch
    335                 continue
--&gt; 336             return self._process_next_batch(batch)
    337 
    338     next = __next__  # Python 2 compatibility

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _process_next_batch(self, batch)
    355         self._put_indices()
    356         if isinstance(batch, ExceptionWrapper):
--&gt; 357             raise batch.exc_type(batch.exc_msg)
    358         return batch
    359 

OSError: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in &lt;listcomp&gt;
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py", line 101, in __getitem__
    sample = self.loader(path)
  File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py", line 147, in default_loader
    return pil_loader(path)
  File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py", line 129, in pil_loader
    img = Image.open(f)
  File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2618, in open
    prefix = fp.read(16)
OSError: [Errno 5] Input/output error
</code></pre>
<p>I have tried restarting my session, but the error just wont go away.</p>

richard: <p>I don’t know how well the dataloader handles I/O errors like that. Does upgrading to pytorch 1.0 help at all?</p>

Ben_Ogie: <p>I haven’t tried upgrading yet. But i wish i knew what caused the error.</p>

Salman_Nauman: <p>Hi <a class="mention" href="/u/ben_ogie">@Ben_Ogie</a>, were you able to fix this error? This error is pretty random. The same worked fine earlier on google colab and it’s not working fine anymore now. Any ideas why this is happening?</p>

chingyu: <p>I got the same issue sometimes. I think this is due to there are too many files in one folder, though sometimes it will work without any modification after a few trials. Maybe you can check this reference.<br>
<a href="https://research.google.com/colaboratory/faq.html#drive-timeout" class="onebox" target="_blank" rel="nofollow noopener">https://research.google.com/colaboratory/faq.html#drive-timeout</a></p>

catafest: <p>I have the same issue with another package … I think the error is from <em>&lt;ipython-input</em>, google colab was upgraded to use python3.8 …</p><aside class="onebox githubcommit" data-onebox-src="https://github.com/googlecolab/backend-info/commit/c43ed71620aa951a5747d40324f1831f0d5e4d84">
  <header class="source">

      <a href="https://github.com/googlecolab/backend-info/commit/c43ed71620aa951a5747d40324f1831f0d5e4d84" target="_blank" rel="noopener nofollow ugc">github.com/googlecolab/backend-info</a>
  </header>

  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Commit">
    <svg width="60" height="60" class="github-icon" viewbox="0 0 14 16" aria-hidden="true"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/googlecolab/backend-info/commit/c43ed71620aa951a5747d40324f1831f0d5e4d84" target="_blank" rel="noopener nofollow ugc">Internal change</a>
    </h4>

    <div class="github-info">
      <div class="date">
        committed <span class="discourse-local-date" data-format="ll" data-date="2022-11-22" data-time="21:48:35" data-timezone="UTC">09:48PM - 22 Nov 22 UTC</span>
      </div>

      <div class="user">
        <a href="https://github.com/metrizable" target="_blank" rel="noopener nofollow ugc">
          <img alt="metrizable" src="https://avatars.githubusercontent.com/u/65414824?v=4" class="onebox-avatar-inline" width="20" height="20">
          metrizable
        </a>
      </div>

      <div class="lines" title="changed 2 files with 16 additions and 16 deletions">
        <a href="https://github.com/googlecolab/backend-info/commit/c43ed71620aa951a5747d40324f1831f0d5e4d84" target="_blank" rel="noopener nofollow ugc">
          <span class="added">+16</span>
          <span class="removed">-16</span>
        </a>
      </div>
    </div>
  </div>
</div>

  <div class="github-row">
    <p class="github-body-container">PiperOrigin-RevId: 490327290</p>
  </div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
maybe this is ?!</p>