出现EOFError: Ran out of input的解决办法

 具体出现错误如下:

出现EOFError: Ran out of input的解决办法_第1张图片

 File "D:\python\CAIL2022-main\sjjc\LEVEN-main\Downstreams\LJP\LJP-Experiment\tools\train_tool.py", line 92, in train
    for step, data in enumerate(dataset):
  File "C:\Users\cong\anaconda3\envs\torch\lib\site-packages\torch\utils\data\dataloader.py", line 445, in __iter__
    return self._get_iterator()
  File "C:\Users\cong\anaconda3\envs\torch\lib\site-packages\torch\utils\data\dataloader.py", line 391, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "C:\Users\cong\anaconda3\envs\torch\lib\site-packages\torch\utils\data\dataloader.py", line 1078, in __init__
    w.start()
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\popen_spawn_win32.py", line 89, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'init_formatter..train_collate_fn'
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Users\cong\anaconda3\envs\torch\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

原因是这个语句运行出错:

for step, data in enumerate(dataset):

打印datasets如下:

 经查,百度等发现需要在pytorch的torch.utils.data.DataLoader中,把参数num_workers(表示进程个数)改为0即可。

在dataloader.py文件第244行修改num_workers = 0

出现EOFError: Ran out of input的解决办法_第2张图片

 问题解决

你可能感兴趣的:(出现EOFError: Ran out of input的解决办法)