动手学深度学习 softmax:RuntimeError: An attempt has been made to start a new process before the current

动手学深度学习 softmax:RuntimeError: An attempt has been made to start a new process before the current,第1张

pycharm无法多进程读取数据导致的报错

问题描述:报错

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.
    ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

解决方法(三选一):

  1. 使用cmd / Anaconda Prompt运行python文件
  2. 将进程数更改为0
def get_dataloader_workers(): 
    return 0
  1. 将需要运行的内容放入if __name__=='__main__':(除定义函数/类之外的内容)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/715156.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存