当前位置: 代码网 > it编程>前端脚本>Python > apex安装常见的三个报错并成功解决(亲测有效)

apex安装常见的三个报错并成功解决(亲测有效)

2024年08月01日 Python 我要评论
TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead.TypeError: unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘AttributeError: module 'torch.distributed' has no attribute '_all_gather_base'

前三个方法我都遇到了错误,直到方法4才成功解决,建议看完全文后再决定使用哪种方法,或者直接使用方法4。

方法1

一开始我使用如下命令进行安装,

pip install apex

安装成功后,进入python,执行语句import apex进行验证是否安装成功,得到报错

typeerror: class advice impossible in python3.  use the @implementer class decorator instead.

方法2

于是在网上找了方法如下,遂将刚才安装的apex卸载,卸载命令为pip uninstall apex,然后根据如下的网上方法安装

git clone https://www.github.com/nvidia/apex
cd apex
python setup.py install

安装好后再次进行验证,得到报错如下

typeerror: unsupported operand type(s) for +: ‘nonetype‘ and ‘str‘

方法3

再次卸载,然后参考https://blog.csdn.net/qq_37844044/article/details/122625442,得到方法如下,相当于把方法2的第三行改为pip install -v --no-cache-dir ./

git clone https://github.com/nvidia/apex.git
cd apex
pip install -v --no-cache-dir ./

安装好后再次验证,得到报错

attributeerror: module 'torch.distributed' has no attribute '_all_gather_base'

方法4

再次卸载,然后参考这篇博文https://blog.csdn.net/weixin_44438120/article/details/112526744,方法如下

git clone https://github.com/ptrblck/apex.git
cd apex
git checkout apex_no_distributed
pip install -v --no-cache-dir ./

再次验证import apex成功(终于不报错了,搞了我两天呜呜呜)

注:遇到报错可以先翻github,比如在安装apex遇到报错时,可以进入https://github.com/nvidia/apex.git,点击issue,输入或粘贴报错查找是否有与自己有相同的问题的issue,看看别人是怎么解决的。最后祝大家好运!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com