请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

windows 下pytorch dataloader num_workers 设置大于0的值 报错

环境:windows10 cuda11.0

dataloader设置:

train_loader = DataLoader(dataset=train_dataset,
                               batch_size=512,
                               shuffle=True,
                               num_workers=0
                          )
test_loader = DataLoader(dataset=test_dataset,
                              batch_size=512,
                              shuffle=False,
                              num_workers=4
                         )

报错:

RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if name == ‘main’:
freeze_support()

The “freeze_support()” line can be omitted if the program
is not going to be frozen to produce an executable.

网上说要把num_workers的值改为0,但是num_wokers太小的话,训练过程很慢。

正在回答 回答被采纳积分+3

2回答

荼灬 2020-12-14 20:08:15

windows下就不能使用num_workers参数

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信