赞
踩
问题关键词:
在训练Swin-Transformer的时候突然出现这问题,让人很是烦,因为之前运行的时候还是好好地,突然就报错了,报错的位置就是enumerate(data_loader)
,之前遇到过这问题但是没有记录下来,又遇到了忘得干干净净。今天记录一下。
train_loader = torch.utils.data.DataLoader(train_dataset,
batch_size=batch_size,
shuffle=True,
pin_memory=True,
num_workers=nw,
collate_fn=train_dataset.collate_fn)
DataLoader
有个参数num_workers
:
这个地方有几个坑:
if __name__ == '__main__':
会报错:Traceback (most recent call last):
File "G:\PyCharm 2021.2.2\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 303, in _on_run
r = r.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "G:\PyCharm 2021.2.2\plugins\python\helpers\pydev\pydevd.py", line 1697, in settrace
stop_at_frame,
File "G:\PyCharm 2021.2.2\plugins\python\helpers\pydev\pydevd.py", line 1764, in _locked_settrace
time.sleep(0.1) # busy wait until we receive run command
KeyboardInterrupt
如果我们debug的时候,num_worker
设置大于1有可能会堵塞,进程不动了,控制台输出:
or from the matplotlib source distribution
Traceback (most recent call last):
File "G:\PyCharm 2021.2.2\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 303, in _on_run
r = r.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
Traceback (most recent call last):
File "G:\PyCharm 2021.2.2\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 303, in _on_run
r = r.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 1023: unexpected end of data
但是这个输出和堵塞是没有关系,我一直以为是报错,结果查了半天,浪费很多时间。具体为什么会堵塞,大家自家查查吧。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。