【Error】pytorch训练网络时报错:RuntimeError: received 0 items of ancdata

pytorch训练网络时报错:RuntimeError: received 0 items of ancdata

错误的原因:dataloader加载数据时,pytorch多线程共享tensor是通过打开文件的方式实现的,而打开文件的数量是有限制的,当需共享的tensor超过open files限制时,即会出现该错误。

解决方案:

1)修改多线程的tensor方式为file_system(默认方式为file_descriptor,受限于open files数量):

#训练python脚本中import torch后,加上下面这句。 
torch.multiprocessing.set_sharing_strategy('file_system')

官方问题链接:

https://github.com/pytorch/pytorch/issues/973

猜你喜欢

转载自blog.csdn.net/chen1234520nnn/article/details/103935825
今日推荐