解决PyTorch DDP: Finding the cause of “Expected to mark a variable ready only once“

这篇具有很好参考价值的文章主要介绍了解决PyTorch DDP: Finding the cause of “Expected to mark a variable ready only once“。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

早上做消融实验的时候需要复现俩月前的实验结果,但是莫名其妙同样的代码和环境却跑不通了,会在loss.backward()的时候报如下错误:
RuntimeError: Expected to mark a variable ready only once. This error is caused by one of the following reasons: 1) Use of a module parameter outside the ``forward`` function. Please make sure model parameters are not shared across multiple concurrent forward-backward passes. 2) Reused parameters in multiple reentrant backward passes. For example, if you use multiple ``checkpoint`` functions to wrap the same part of your model, it would result in the same set of parameters been used by different reentrant backward passes multiple times, and hence marking a variable ready multiple times. DDP does not support such use cases yet.

在网上找了一圈发现一共也没几个人问过这个报错,其中stackoverflow上有人解决了这问题,说是把find_unused_parameters设置为false就莫名其妙好了,但是我这么设置之后在固定D训练G的时候又报错:之前写代码时碰到了这样一个错误:
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 (1) passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel; (2) making sure all forward function outputs participate in calculating loss. If you already have done the above two steps, 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).
解决PyTorch DDP: Finding the cause of “Expected to mark a variable ready only once“,pytorch,人工智能,python
但解决“Expected to have finished reduction in the prior iteration before starting a new one”又涉及到把find_unused_parameters设置为True,这看起来直接和上面的解决方法矛盾了…文章来源地址https://www.toymoban.com/news/detail-734328.html

最后实在是无可奈何,觉得可能是因为单卡采用分布式训练出了啥问题,于是干脆把ddp给关了再训练,报错才得以解决,太玄学了。。。

到了这里,关于解决PyTorch DDP: Finding the cause of “Expected to mark a variable ready only once“的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 解决Error:Kotlin报错The binary version of its metadata is 1.5.1, expected version is 1.1.16问题

    idea 2020.2.3 问题描述: idea以springboot方式启动微服务应用,但是编译过程中idea报错: Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16. 但是maven编译不报错误正常编译了,说明问题不是包的引用,应该是idea本身的问

    2024年02月12日
    浏览(26)
  • The database operation was expected to affect 1 row(s), but actually affected 0 row(s); 解决乐观并发

    EF Core 实现 乐观并发 ,假定并发冲突相对较少。 与 悲观 方法(即先锁定数据,然后才继续修改数据)不同,乐观并发不需要锁定,而是安排数据修改在保存时失败(如果数据自查询后已更改)。 此并发故障将报告给应用程序,应用程序可能会通过对新数据重试整个操作来

    2024年02月11日
    浏览(37)
  • pytorch异常——RuntimeError:Given groups=1, weight of size..., expected of...

    nn.Conv2d 需要的输入张量格式为 (batch_size, channels, height, width),但您的示例输入张量 x 是 (batch_size, height, width, channels)。因此,需要对输入张量进行转置。 注意, TensorFlow使用\\\"NHWC\\\"(批次、高度、宽度、通道)格式,而PyTorch使用\\\"NCHW\\\"(批次、通道、高度、宽度)格式 在pytorch中

    2024年02月10日
    浏览(45)
  • 【】解决minio启动报ERROR Unable to use the drive ** found backend type fs, expected xl or xl-single

    由于minio报了一个安全漏洞(MinIO verify 接口敏感信息泄露漏洞分析(CVE-2023-28432)_minio 漏洞_超酸柠檬的博客-CSDN博客),以至于公司需要升级minio版本,但是我发现使用最新版本的minio后minio无法正常启动了。由于之前就是单机部署,因此这次还是单机部署,结果却启动不起来了

    2023年04月24日
    浏览(80)
  • 解决File ~ could only be written to 0 of the 1 minReplication nodes.

    在通过javaApi上传本地文件时出现以下错误,主要原因是: File /test3.txt could only be written to 0 of the 1 minReplication nodes. There are 1 datanode(s) running and 1 node(s) are excluded in this operation. 但是之前还能解决向hdfs创建目录,为什么不能上传文件嘞?按理说权限不应该有问题,那具体是什么

    2023年04月08日
    浏览(65)
  • Android 打包出现The binary version of its metadata is 1.6.0, expected version is 1.4.0(*.*.*)

    你的gradle插件使用的是1.6.0,但是你引入的第三库使用的低版本。 解决办法有3种。个人建议使用第三种 1、降低 gradle版本,4.0.1版本使用的是1.4.0 2、忽略检查后打包会明显加快。但是你懂的。 3、统一使用指定版本。这样就统一使用指定版本了 配置如下:  备注:使用了第三库

    2024年02月11日
    浏览(36)
  • 打包过程遇到的问题:The binary version of its metadata is 1.6.0, expected version is 1.4.0

    Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0. 你的gradle插件使用的是1.6.0,但是你引入的第三库使用的低版本。 方案一: 降低 gradle版本,4.0.1版本使用的是1.4.0 方案二: 忽略检查后打包会明显加快 方案三: (这是比较推

    2024年02月03日
    浏览(31)
  • 成功解决RuntimeError: Failed to import transformers.models.llama.tokenization_llama_fast because of the

    成功解决RuntimeError: Failed to import transformers.models.llama.tokenization_llama_fast because of the following error (look up to see its traceback): tokenizers=0.13.3 is required for a normal functioning of this module, but found tokenizers==0.12.1 目录 解决问题 解决思路 解决方法 T1、pip命令 T2、conda命令 RuntimeError: Failed to im

    2024年02月11日
    浏览(37)
  • 彻底解决this version of the Java Runtime only recognizes class file versions up to 52.0

    这个错误的意思是当时开发程序的人使用的JDK的版本要比你现在运行的环境上的JDK版本高。比如他是使用JDK11开发的,然后把程序打包好,你下载了他的jar包到本地运行,然后报错,可能你本地的JDK版本是低于11的,所以报错。 安装JDK21就行。继续看文章下面的对应关系,就知

    2024年02月02日
    浏览(42)
  • 【已解决】this version of the Java Runtime only recognizes class file versions up to 52.0

    在把springboot项目打包了jar之后,准备本地运行一下 然后报错: 编译版本和运行版本不一致,可能是编译版本高于运行版本导致的 修改pom.xml, 将此版本改为 java -version 版本 为 spring-boot-maven-plugin 增加 parent的版本号 如果没指定spring-boot-maven-plugin 的版本,就会拿取最新的版本打

    2023年04月16日
    浏览(95)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包