1.BrokenPipeError
執行以下命令時:
a,b = iter(train_loader).next()
報錯:BrokenPipeError: [Errno 32] Broken pipe
錯誤原因:子進程原因
On Windows the subprocesses will import (i.e. execute) the main module at start. You need to insert an if __name__ == '__main__': guard in the main module to avoid creating subprocesses recursively.
解決方法:
Please see my edited response where I did exactly that. The requirement for wrapping the code inside of if __name__ == '__main__'
code isn't immediately obvoius, as it is only required for Windows machines.就是說在windows下必須將上面的代碼打包在if __name__ == '__main__'語句下面。這時不會報錯了。
還有人說:I also got the same error. When I set num_workers to 0, the error does not appear again. However, when I set num_workers to 1, the error is still there.即將如下:
train_loader = data.DataLoader(dataset, batch_size=64, shuffle=True, num_workers=2, drop_last=False)
代碼中的num_workers=0,但我改了以后還回報另外的錯誤。
2. 發現gpu並行運算出錯,單個gpu沒問題.
重新裝了驅動:ubuntu18.04-rtx2080ti-nvidia driver 410.78-cuda9.0-cudnn-9.0-v7.5.1.10-將gcc和g++降級為4.8.