ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:

ImportError:cannot import name ‘save_state_warning’ from torch.optim.lr_scheduler’.

我看到很多人方法是把torch版本改为1.7.1版本,或者是提高transformers。
这里我提供一下下载1.7.1的命令:

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

如果报告超时错误,请添加镜像。

[En]

Add a mirror image if you report a timeout error.

-i https://pypi.tuna.tsinghua.edu.cn/simple

然后我这里还有个方法,因为我需要1.8.1的,我用1.7.1的时候报torch的分布式错误No rendezvous handler for env。很麻烦,好像是因为1.7.1对应的cuda10.1是不能在windows跑的,得去linux的ubuntu,要在window跑是需要11.0以上版本估计。

ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:

所以我陷入了循环,但我坚持使用1.8.1版,后来我仔细研究了这个错误。

[En]

So I got into a loop, but I stuck to version 1.8.1, and later I looked at the error carefully.

ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:
首先报的错是没有SAVE_STATE_WARNING,这里这个文件(lr_scheduler)进去之后,确实你会发现找不到SAVE_STATE_WARNING。但是很巧我之前用了1.7.1的torch,我就去看1.7.1版本的lr_scheduler.py文件。确实有不同,也有SAVE_STATE_WARNING。所以我大胆的将1.7.1的lr_scheduler.py替换了1.8.1的lr_scheduler.py。下图看到1.7.1是有save_state_warning,但是我不是只复制一行代码,你们可以试试只复制一行代码去1.8.1的lr_scheduler文件里,我是直接全部覆盖的。
ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:

结果,我惊讶地发现我不会犯错误,我也不会报告1.7.1分布式错误。这里我还分享了1.8.1的下载命令。

[En]

As a result, I was surprised to find that I wouldn’t make a mistake, and I wouldn’t have reported the 1.7.1 distributed error. Here I also share the download command of 1.8.1.

pip install  -i https://pypi.tuna.tsinghua.edu.cn/simple torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

这里也提到分布式错误,我是windows环境跑代码,所以需要改行代码

ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:
再加上这个。现在我很高兴可以运行代码了。我一直在训练。我希望不会出差错。数十万条数据在运行,如果出现问题,我们必须重新检查并重新开始。
[En]

Add this. Now I’m happy to run the code. I’ve been training all the time. I hope it won’t go wrong. Hundreds of thousands of pieces of data are running, and if something goes wrong, we have to check it and start all over again.

总结一下就是。
一开始我torch1.7.1环境下报No rendezvous handler for env这样的分布式错误,网上查找大概原因是我torch1.7.1对应的cuda10.1是不能在windows下跑的。所以我放弃了1.7.1,使用了1.8.1的torch。这样出现新的错误是ImportError:cannot import name ‘save_state_warning,这样我就把1.7.1里面的lr_scheduler.py文件覆盖掉1.8.1的lr_scheduler.py文件,这样就没有问题了。

Original: https://blog.csdn.net/weixin_42746744/article/details/124136416
Author: MASTER-松哥
Title: ImportError:cannot import name ‘save_state_warning‘和解决torch1.7.1报分布式错误No rendezvous handler for env:

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/527469/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球