BrokenPipeError: [Errno 32] Broken pipe

运行Pytorch tutorial代码报错:BrokenPipeError: [Errno 32] Broken pipe

源代码地址: Training a classifier (CIFAR10)

该问题的产生是由于windows下多线程的问题,和DataLoader类有关,具体细节点这里Fix memory leak when using multiple workers on Windows

解决方案:

    修改调用torch.utils.data.DataLoader()函数时的 num_workers 参数。该参数官方API解释如下: 

  • num_workers (int, optional) – how many subprocesses to use for data loading. 0 
    means that the data will be loaded in the main process. (default: 0)

    该参数是指在进行数据集加载时,启用的线程数目。截止当前2018年5月9日11:15:52,如官方未解决该BUG,则可以通过修改num_works参数为 ,只启用一个主进程加载数据集,避免在windows使用多线程即可。

转自:https://blog.csdn.net/u014380165/article/details/79058479

原文地址:https://www.cnblogs.com/gmhappy/p/11863967.html