Pytorch报错记录

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.
解决方法:

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.