【问题总结】PyCharm运行报错:BrokenPipeError: [Errno 32] Broken pipe

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

源代码地址:https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#sphx-glr-beginner-blitz-cifar10-tutorial-py

该问题的产生是由于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参数为 0 ,只启用一个主进程加载数据集,避免在windows使用多线程即可。

【解释参考】

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

猜你喜欢

转载自www.cnblogs.com/ITCSJ/p/11453211.html