在使用由自定义数据集制作的 Pytorch 数据加载器进行神经网络训练期间,我遇到了奇怪的行为。数据加载器设置为workers=4、pin_memory=False。
\n大多数时候,训练都没有问题地完成。\n有时,训练会随机停止,并出现以下错误:
\n看起来错误发生在创建套接字以访问数据加载器元素期间。\n当我将工作线程数设置为 0 时,该错误消失,但我需要通过多处理来加速我的训练。\n错误的根源可能是什么?谢谢 !
\nPython 3.9.12,Pyorch 1.11.0+cu102
\n编辑:该错误仅发生在集群上
Traceback (most recent call last):\n File "/my_directory/.conda/envs/geoseg/lib/python3.9/multiprocessing/resource_sharer.py", line 145, in _serve\nEpoch 17: 52%|\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x8f | 253/486 [01:00<00:55, 4.18it/s, loss=1.73]\n\nTraceback (most recent call last):\n File "/my_directory/bench/run_experiments.py", line 251, in <module>\n send(conn, destination_pid)\n File "/my_directory/.conda/envs/geoseg/lib/python3.9/multiprocessing/resource_sharer.py", line 50, in send\n reduction.send_handle(conn, new_fd, pid)\n File "/my_directory/.conda/envs/geoseg/lib/python3.9/multiprocessing/reduction.py", line 183, in send_handle\n with socket.fromfd(conn.fileno(), socket.AF_UNIX, …Run Code Online (Sandbox Code Playgroud)