title: Dataloader worker exited unexpectedly while running on Visual Studio. But runs okay on Google Colab
body: <p><strong>So I have this dataloader that loads data from hdf5 but exits unexpectedly when I am using num_workers&gt;0 (it works ok when 0). More strangely, it works okay with more workers on google colab, but not on my computer.
  On my computer I have the following error:</strong></p>
  <p>Traceback (most recent call last):
  File &quot;C:\Users\Flavio Maia\AppData\Roaming\Python\Python37\site-packages\torch\utils\data\dataloader.py&quot;, line 986, in _try_get_data
  data = self._data_queue.get(timeout=timeout)
  File &quot;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\multiprocessing\queues.py&quot;, line 105, in get
  raise Empty
  _queue.Empty</p>
  <p>The above exception was the direct cause of the following exception:</p>
  <p>Traceback (most recent call last):
  File &quot;&quot;, line 2, in 
  File &quot;C:\Users\Flavio Maia\AppData\Roaming\Python\Python37\site-packages\torch\utils\data\dataloader.py&quot;, line 517, in <strong>next</strong>
  data = self._next_data()
  File &quot;C:\Users\Flavio Maia\AppData\Roaming\Python\Python37\site-packages\torch\utils\data\dataloader.py&quot;, line 1182, in _next_data
  idx, data = self._get_data()
  File &quot;C:\Users\Flavio Maia\AppData\Roaming\Python\Python37\site-packages\torch\utils\data\dataloader.py&quot;, line 1148, in _get_data
  success, data = self._try_get_data()
  File &quot;C:\Users\Flavio Maia\AppData\Roaming\Python\Python37\site-packages\torch\utils\data\dataloader.py&quot;, line 999, in _try_get_data
  raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
  RuntimeError: DataLoader worker (pid(s) 12332) exited unexpectedly</p>
  <p><strong>Also, my getitem function is:</strong></p>
  <pre><code>def __getitem__(self,index):
    desired_file = int(index/self.file_size)
    position = index % self.file_size 
  
    h5_file = h5py.File(self.files[desired_file], 'r')
  
    image = h5_file['Screenshots'][position]
    rect = h5_file['Rectangles'][position]
    numb = h5_file['Numbers'][position]
  
    h5_file.close()
  
    image = torch.from_numpy(image).float() 
    rect = torch.from_numpy(rect).float() 
    numb = torch.from_numpy( np.asarray(numb) ).float()
  
  
    return (image, rect, numb)
  </code></pre>
  <p>Does anyone have any idea what can be causing this empty queue?</p>