Advertisement

RuntimeError: An attempt has been made to start a new process before the current pr

阅读量:

pytorch 加载数据时报错:

An attempt was initiated to begin a new process prior to the completion of the bootstrapping phase by the current process.

This likely indicates that you are not employing the fork mechanism for spawning child processes and have overlooked using the correct idiom in the main module:

if name == 'main':
freeze_support()
...

It is possible to remove the 'freeze_support()' line if the program is not intended to be frozen and produce an executable file.

复制代码
 dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=opt.batchsize,

    
                                           shuffle=False, num_workers=0) for x in

该系统依赖于main函数进行多进程执行。

解决方法1:

加main函数,在main中调用,继续多进程加载,可以加速

解决方法2:

num_workers改为0,单进程加载,速度会慢点。

全部评论 (0)

还没有任何评论哟~