Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

pytorch - TypeError: cannot serialize '_io.TextIOWrapper' object

I'm using rtx 3080, python 3.7, torch 1.7.1, torchvision 0.8.2

i tried chaning python version and batch size etc. But doesn't work..

what can i do to fix this problem

Traceback (most recent call last):
  File "run_captioning.py", line 882, in <module>
    main()
  File "run_captioning.py", line 861, in main
    global_step, avg_loss = train(args, train_dataset, val_dataset, model, tokenizer)
  File "run_captioning.py", line 424, in train
    for step, (img_keys, batch) in enumerate(train_dataloader):
  File "C:UsersUser.condaenvspy37libsite-packagesorchutilsdatadataloader.py", line 352, in __iter__
    return self._get_iterator()
  File "C:UsersUser.condaenvspy37libsite-packagesorchutilsdatadataloader.py", line 294, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "C:UsersUser.condaenvspy37libsite-packagesorchutilsdatadataloader.py", line 801, in __init__
    w.start()
  File "C:UsersUser.condaenvspy37libmultiprocessingprocess.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:UsersUser.condaenvspy37libmultiprocessingcontext.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:UsersUser.condaenvspy37libmultiprocessingcontext.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:UsersUser.condaenvspy37libmultiprocessingpopen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "C:UsersUser.condaenvspy37libmultiprocessing
eduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot serialize '_io.TextIOWrapper' object

(py37) D:Oscaroscar>Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:UsersUser.condaenvspy37libmultiprocessingspawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:UsersUser.condaenvspy37libmultiprocessingspawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
question from:https://stackoverflow.com/questions/65856075/typeerror-cannot-serialize-io-textiowrapper-object

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

it is a problem in window compiler.

only linux provides the function.

when i run this code with wsl, the error was disappeared.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...