Tag Archives: EOFError: Ran out of input

[Solved] Python error: EOFError: Ran out of input

Python error: EOFError: Ran out of input

Error when running pickle-related functions: EOFError: Ran out of input

Previous code.

>>> import pickle
>>> s = pickle.load(fp)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
EOFError: Ran out of input

Cause analysis: to open a file in file operation mode

Solution:

Change to the following method

>>> fp = open("a.txt","rb+")
>>> import pickle
>>> s = pickle.load(fp)#Serialized Print Results
['apple', 'mango', 'carrot']

 

[How to Solve Pytorch Error] EOFError: Ran out of input

The specific errors encountered in training models with pytorch under windows are as follows.

Traceback (most recent call last):
File “train.py”, line 49, in <module>
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 <function <lambda> at 0x000000001BD9E048>: a
ttribute lookup <lambda> on __main__ failed
Traceback (most recent call last):
File “<string>”, line 1, in <module>
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

This error is actually a pytorch function torch.utils.data.DataLoader in the windows-specific error, the function has a parameter num_workers to indicate the number of processes, in windows to change to 0 can be.

https://discuss.pytorch.org/t/pytorch-windows-eoferror-ran-out-of-input-when-num-workers-0/25918/2