PyTorch:The “freeze_support()“ line can be omitted if the program is not going to be frozen
程序员文章站
2024-01-01 09:34:28
...
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.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.
我的原因是运行了多线程,
train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=True, num_workers=2, drop_last=True)
将2改为0就可以了。
推荐阅读
-
The “freeze_support()“ line can be omitted if the program is not going to be frozen to prod解决方法
-
Python:The “freeze_support()“ line can be omitted if the program is not going to be frozen
-
The “freeze_support()“ line can be omitted if the program is not going to be frozen to produ
-
PyTorch:The “freeze_support()“ line can be omitted if the program is not going to be frozen
-
PyTorch:The “freeze_support()” line can be omitted if the program is not going to be frozen