使用DDP时出现错误,但是单卡跑无错误。

错误记录如下:

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel, and by

making sure all forward function outputs participate in calculating loss.

If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).

Parameter indices which did not receive grad for rank 1: 4 5 6 7

In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error

一度以为是DDP的bug,仔细阅读报错发现,关键在于

This error indicates that your module has parameters that were not used in producing loss.

即有参数未参与到loss生成过程中,换句话说就是有参数在init中定义,但是未在forward中使用,就会造成这样的结果。原来为了不断调优模型,我将几个待选网络模块都写在了init函数中,然后这样只需要在forward中改变调用的模块就可以了。在单机运行中这样是可行的无错的,但是在DDP中由于需要多卡进行loss的reduce,为了防止出错,ddp就强行设置了这样的规则,但是可以通过如上错误提示里面的参数更改此设置,但是尽量不要修改。

解决方法:将init函数中未使用到的模块注释掉即可。

DDP运行报错(单卡无错):ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1)的更多相关文章

  1. 鸿蒙运行报错:Failure[INSTALL_PARSE_FAILED_USESDK_ERROR] Error while Deploying HAP

    问题描述 近期,使用DevEco-Studio新建手机类型的工程,编译成功,发布到模拟器(鸿蒙P40)时出错,如下图: 原因分析 本地DevEco-Studio使用的SDK版本与设备(P40)不匹配导 ...

  2. Selenium Grid 运行报错 Exception thrown in Navigator.Start first time ->Error forwarding the new session Empty pool of VM for setup Capabilities

    Selenium Grid 运行报错 : Exception thrown in Navigator.Start first time ->Error forwarding the new se ...

  3. Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer

    Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1.  Start heka ...

  4. sublime text3 当运行报错error时,取消显示路径path的方法

    sublime text3 每当运行报错error时,都会出现一长串的path路径,如何不显示呢? 可以通过注释掉Packages/Default/exec.py的四个特定行来更改. 首先,您需要从P ...

  5. 单点登录(五)-----遇到问题-----cas server 源码部署tomcat运行报错BeanCreationException:Error creating bean with name 's

    我们在上一篇文章已经解决了把下载好的cas server源码部署到tomcat缺少子项目编辑文件或者jar包导致找不到class报错的问题 单点登录(四)-----遇到问题-----cas serve ...

  6. appium运行报错java.net.SocketException: socket write error

    这个错我调了 快两天一点头绪没有,脚本正常跑没问题,但是就是控制台输出信息报错,没法定位问题在哪.报错如图: 虽然这个报错不影响测试结果,但是本人有强迫症,一定要查出究竟: 我的尝试: 1.那天试验, ...

  7. react native-调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错

    调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错,而在iOS上运行没问题.原因是因为接口是有验证信息的,而调用这个插件时没有传入,在iOS上会自动加 ...

  8. vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题

    vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题 今天下载了一个开源项目一直运行不了,折腾了半天才找到问题所在,config ...

  9. 模拟器运行报错:ld: symbol(s) not found for architecture x86_64

    模拟器运行报错: 报错信息如下: Undefined symbols for architecture x86_64: "_x264_encoder_open_142", refe ...

  10. 单点登录(四)-----遇到问题-----cas server 源码部署tomcat运行报错ClassNotFoundException: org.jasig.cas.CasEnvironmentCo

    情况 cas单点登录 cas server 源码部署tomcat运行报错 把cas server的代码下载下来后使用gradle插件或者maven插件以及转化成eclipse·后导入发现部署到tomc ...

随机推荐

  1. MinIO客户端之cp

    MinIO提供了一个命令行程序mc用于协助用户完成日常的维护.管理类工作. 官方资料 mc cp 上传文件至指定桶内,命令如下: ./mc cp ./local.json local1/bkt1/ 控 ...

  2. cp {,bak}用法(转载)

    cp filename{,bak} cp filename{,.bak} 这个命令是用来把filename备份成filename.bak的 等同于命令 cp filename filename.bak ...

  3. 不是银趴~是@Import!

    首先我们要明确:@Import 注解是 Spring 提供的. 然后我们看一下该注解的官方注释: Indicates one or more component classes to import - ...

  4. IPv6通过公网共享文件(Windows)

    前言 之前讲了如何使用IPv6进行内网穿透,这种方案实现的穿透是免费且不限速的.那么实现穿透后,我们就可以将原本Windows自带的共享功能的范围从局域网扩大到整个公网,从而实现随时随地都能访问到共享 ...

  5. Vue 2 和 Vue 3 中 toRefs的区别

    摘要:本文将介绍 Vue 2 和 Vue 3 中 toRefs 函数的不同用法和行为,并解释其在各个版本中的作用. 正文: Vue 是一款流行的 JavaScript 框架,用于构建用户界面.在 Vu ...

  6. linux 账号管理 添加用户与修改用户权限与密码

    添加用户 useradd zhoulujun 修改用户密码 passwd  zhoulujun 修改用户组 usermod -g root  zhoulujun 记住这个几个就够了--

  7. html jquery from 表单提交 application/x-www-form-urlencoded 改成 json

    html jquery from 表单提交 $(form).ajaxSubmit  application/x-www-form-urlencoded  改成 json 要使用 jQuery 根据 n ...

  8. HanLP — HMM隐马尔可夫模型 -- 语料库

    隐马尔可可夫模型(Hidden Markov Model,HMM)是统计模型,用于描述一个含有隐含未知参数的马尔可夫过程. HMM由初始概率分布.状态转移概率分布和观测概率分布确定. BMES =&g ...

  9. .NetCore 接口请求耗时记录

    通过日志,记录每个接口请求的耗时情况 结合  <logger name="*" level="Trace" writeTo="tracefile ...

  10. JMeter 源码解读 - HashTree

    背景: 在 JMeter 中,HashTree 是一种用于组织和管理测试计划元素的数据结构.它是一个基于 LinkedHashMap 的特殊实现,提供了一种层次结构的方式来存储和表示测试计划的各个组件 ...