报错信息显示 pytorch 的 DataLoader 无法正确加载。
造成这个报错的原因不尽相同,但是猜测,大体上都是程序不知为何无法开启新的线程,导致线程被系统终止。当线程数设为 0 时正常(num_worker
=0)
对于我来说,发现问题出现在使用 vscode 调试 pytorch 训练代码。如果是命令行运行则没问题。
参考:
python - RuntimeError: DataLoader worker exited unexpectedly - Stack Overflow
If you are working on jupyter notebook. The problem is more likely to be num_worker. You should set num_worker=0.
Dataloader worker exited unexpectedly · Issue #28820 · pytorch/pytorch
标签:signal,DataLoader,worker,pytorch,num,线程,RuntimeError From: https://www.cnblogs.com/zkmjolnir/p/17615407.htmlI fixed it by adding: cv2.setNumThreads(0) at the beginning of my script.