pytorch 加载数据时报错:

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.

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,单进程加载,速度会慢点。

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

  1. python 多线程报错An attempt has been made to start a new process before the current process has finished

    报错信息: An attempt has been made to start a new process before the current process has finished its 原因 ...

  2. An attempt has been made to start a new process before the current process has finished its

    必须在 if __name__=='__main__': 后运行

  3. An attempt has been made to start a new process before the current process

    解决方法: 1.去掉num_workers参数(或者将num_workers=0) 你直接crtl+shift+F全局搜索num_workers,然后让它等于0就可以解决 2.在跑epoch之前,加上 ...

  4. python编程问题--第四次

    20220317 https://www.cnblogs.com/Lival/p/6203111.html raise发明一个异常 20220228 orderedItem = [v[0] for v ...

  5. python runtime错误_python出现RuntimeError错误

    runtimeerror,python出现RuntimeError错误 RuntimeError: An attempt has been made to start a new process be ...

  6. python多进程原理_python多进程的详细介绍(附示例)

    本篇文章给大家带来的内容是关于PHP中的SAPI是什么?如何实现?(图文),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 进程 Python是运行在解释器中的语言,查找资料知道,py ...

  7. 医学数据挖掘学习项目:他克莫司

    目录 1. 报告 2. 代码1:从数据库中提取数据 lambda,匿名函数,快速定义单行函数,可以用在任何需要函数的地方. numpy.array 和 python.array python.filt ...

  8. python大佬养成计划-----多进程

    进程 Python是运行在解释器中的语言,查找资料知道,python中有一个全局锁(GIL),在使用多进程(Thread)的情况下,不能发挥多核的优势.而使用多进程(Multiprocess),则可以 ...

  9. dataloader 源码_[莫烦 PyTorch 系列教程] 3.5 – 数据读取 (Data Loader)

    请教一个问题: 在遍历"for step, (batch_x, batch_y) in enumerate(loader): "这一步会报这样的错误: raceback (most ...

最新文章

  1. ideal如何创建dynamic web project
  2. Nginx 出现504 Gateway Time-out的解决方法
  3. ajax后台如何把对象转为json_57. Django 2.1.7 查询数据返回json格式
  4. 裁员这件事,谁也没有鲍尔默、纳德拉这两届微软CEO演绎的淋漓尽致
  5. 第一周:信息系统项目管理基础与立项管理作业视频讲解
  6. 高斯滤镜模糊CSS3
  7. C++对象内存布局--④VS编译器--单个虚拟继承
  8. java 特殊字符过滤器_java处理url中的特殊字符
  9. ubuntu下lvs负载均衡dr模型shell脚本
  10. Android系列之Fragment(三)----Fragment和Activity之间的通信(含接口回调)
  11. mac使用bootcamp安装win7遇到的一些坑
  12. 小型超市管理系统.c
  13. za压缩图片的几种方法
  14. java ftl_.ftl文件 是什么文件 freemaker
  15. python爬虫登录微博_[突如其来]python爬虫模拟登录微博
  16. 微软通过云存储插件简化Docker容器迁移
  17. Flyway数据库版本管理工具
  18. Data Base学习记录:ODL
  19. sd 0:0:0:0: [sda] Assuming drive cache: write through错误解决 本人实测!
  20. hive中的distribute by、sort by、cluster by

热门文章

  1. Linux内核--各种宏定义
  2. 马斯克学什么计算机语言,马斯克头脑风暴——对计算机如醉如痴
  3. 主机电源全是黑线怎么短接_汽车胎压监测即将成为强制标准,听听老司机怎么说...
  4. NeHe教程Qt实现——lesson12
  5. 二数和,三数和,四数和的优化总结
  6. UDP如何实现可靠传输
  7. html中多边形图形怎么制作,CSS制作图形速查表
  8. cesium 加载bim模型_构建统一CIM数字底盘,实现基于BIM的全流程管控
  9. 微服务架构_企业中的微服务:敌是友?
  10. java中把字符串转换为日期,java字符串转日期方法,java如何将字符串转为日期?...