Notes

Error

---------------------------------------------------------------------------
Empty                                     Traceback (most recent call last)
P:\miniconda3\envs\DL\lib\site-packages\torch\utils\data\dataloader.py in _try_get_data(self, timeout)
   1010         try:
-> 1011             data = self._data_queue.get(timeout=timeout)
   1012             return (True, data)

P:\miniconda3\envs\DL\lib\multiprocessing\queues.py in get(self, block, timeout)
    104                     if not self._poll(timeout):
--> 105                         raise Empty
    106                 elif not self._poll():

Empty: 

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5236/2715232638.py in <module>
      1 lr, num_epochs, batch_size = 1.0, 10, 256
      2 train_iter, test_iter = d2l.load_data_fashion_mnist(batch_size)
----> 3 d2l.train_ch6(net, train_iter, test_iter, num_epochs, lr, d2l.try_gpu())

P:\miniconda3\envs\DL\lib\site-packages\d2l\torch.py in train_ch6(net, train_iter, test_iter, num_epochs, lr, device)
    510         metric = d2l.Accumulator(3)
    511         net.train()
--> 512         for i, (X, y) in enumerate(train_iter):
    513             timer.start()
    514             optimizer.zero_grad()

P:\miniconda3\envs\DL\lib\site-packages\torch\utils\data\dataloader.py in __next__(self)
    528             if self._sampler_iter is None:
    529                 self._reset()
--> 530             data = self._next_data()
    531             self._num_yielded += 1
    532             if self._dataset_kind == _DatasetKind.Iterable and \

P:\miniconda3\envs\DL\lib\site-packages\torch\utils\data\dataloader.py in _next_data(self)
   1205 
   1206             assert not self._shutdown and self._tasks_outstanding > 0
-> 1207             idx, data = self._get_data()
   1208             self._tasks_outstanding -= 1
   1209             if self._dataset_kind == _DatasetKind.Iterable:

P:\miniconda3\envs\DL\lib\site-packages\torch\utils\data\dataloader.py in _get_data(self)
   1171         else:
   1172             while True:
-> 1173                 success, data = self._try_get_data()
   1174                 if success:
   1175                     return data

P:\miniconda3\envs\DL\lib\site-packages\torch\utils\data\dataloader.py in _try_get_data(self, timeout)
   1022             if len(failed_workers) > 0:
   1023                 pids_str = ', '.join(str(w.pid) for w in failed_workers)
-> 1024                 raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
   1025             if isinstance(e, queue.Empty):
   1026                 return (False, None)

RuntimeError: DataLoader worker (pid(s) 19636, 18980, 19832) exited unexpectedly

Resolution

for example: d2l package

def get_dataloader_workers():
    """Use 4 processes to read the data.

    Defined in :numref:`sec_fashion_mnist`"""
    return 4
# 把 4 改为 0
This is just a placeholder img.