EOFError: Ran out of input

在windows下用pytorch 训练模型遇到的具体错误如下:

Traceback (most recent call last):
  File "train.py", line 49, in
    data_loader_iter = iter(data_loader)
  File "D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 501
, in __iter__
    return _DataLoaderIter(self)
  File "D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 289
, in __init__
    w.start()
  File "D:\anaconda3\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "D:\anaconda3\lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\anaconda3\lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)
  File "D:\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 66, in __in
it__
    reduction.dump(process_obj, to_child)
  File "D:\anaconda3\lib\multiprocessing\reduction.py", line 59, in dump
    ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle at 0x000000001BD9E048>: a
ttribute lookup on __main__ failed
Traceback (most recent call last):
  File "", line 1, in
  File "D:\anaconda3\lib\multiprocessing\spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
  File "D:\anaconda3\lib\multiprocessing\spawn.py", line 116, in _main
    self = pickle.load(from_parent)
EOFError: Ran out of input

这个错误其实是pytorch函数torch.utils.data.DataLoader在windows下的特有错误,该函数里面有个参数num_workers表示进程个数,在windows下改为0就可以了,这个解答是在外国友人那边看到的,具体链接如下:https://discuss.pytorch.org/t/pytorch-windows-eoferror-ran-out-of-input-when-num-workers-0/25918/2

 

你可能感兴趣的:(pytorch)