[debug] PyTorch报错:ConnectionResetError: [Errno 104] Connection reset by peer

问题描述:

使用PyTorch 1.10.0,训练报错:

ConnectionResetError: [Errno 104] Connection reset by peer

问题解析

参见pytorch的issue

I believe the issue is only triggered for the case that both
persistent_workers and pin_memory are turned on and iteration is
terminated at the time that worker is sending data to queue. First,
persistent worker would keep iterator with workers running without
proper cleaning up (using __del__ in _MultiProcessingDataLoaderIter.
And, if any background worker (daemon process) is terminated when it
is sending data to the _worker_result_queue, such Error would be
triggered as the pin_memory_thread want to get such data from Queue.

I can send a PR

解决方法

目前的解决方法是增大batchsize,或者可以尝试issue中的其他方法

I have experienced this issue as well where the dataloader exits with a ConnectionResetError: [Errno 104] Connection reset by peer error. I observed that this error goes away away with either a) adding a sleep, or b) using larger batch sizes. I suspect there is race condition that is triggered if the dataloader completes very quickly. I am running Pytorch 1.10.

回答:Pytorch中,当出现ConnectionResetError: [Errno 104 Connection reset by peer错误时,有几种可能的解决方法。其中一种可能是由于发送的数据大小超过了服务器的限制,导致服务器重置了连接。可以尝试减小发送数据的大小或者分批发送。另外,也有用户反馈在数据加载器(DataLoader)完成得非常快时,可能会出现这个错误。可以尝试添加适当的延时或者增加批次大小(batch size)来解决。总的来说,这个错误可能是由于连接重置导致的,需要根据具体情况采取相应的解决方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [[Python] ConnectionResetError: [Errno 104] Connection reset by peer](https://blog.youkuaiyun.com/wawa8899/article/details/51759477)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *3* [[debug] PyTorch报错ConnectionResetError: [Errno 104] Connection reset by peer](https://blog.youkuaiyun.com/qq_41683065/article/details/122643637)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值