首页 > 其他分享 >报错--RuntimeError: Too many open files. Communication with the workers is no longer possible.

报错--RuntimeError: Too many open files. Communication with the workers is no longer possible.

时间:2022-11-16 21:11:19浏览次数:271  
标签:files longer RuntimeError torch 报错 Too open workers

问题描述

pytorch 的 dataloader 在读取数据时,设置了较大的 batchsize 和 num_workers. 然后训练一段时间报错:

RuntimeError: Too many open files. Communication with the workers is no longer possible. Please increase the limit using ulimit -n in the shell or change the sharing strategy by calling torch.multiprocessing.se t_sharing_strategy('file_system') at the beginning of your code

解决方法

在代码开头引入 torch 之后加上:

import torch.multiprocessing
torch.multiprocessing.set_sharing_strategy('file_system')

标签:files,longer,RuntimeError,torch,报错,Too,open,workers
From: https://www.cnblogs.com/ltkekeli1229/p/16897522.html

相关文章