AttributeError: module ‘torch.distributed‘ has no attribute ‘deprecated‘问题解决方案

问题

在参加一个分类比赛的时候down了一套demo用来做比赛,但是在导入from apex.parallel import DistributedDataParallel as DDP的时候提示错误:

AttributeError: module ‘torch.distributed‘ has no attribute ‘deprecated‘

解决方法:AttributeError: module ‘torch.distributed‘ has no attribute ‘deprecated‘

首先我的torch版本是1.5.1,CUDA是10.1。在最开始的时候我使用Phoenixtree_Zhao博客的方法:

  1. 如果已经安装过 apex,需要先卸载它:(windows10 环境下,打开 cmd)
pip uninstall apex
rm -rf apex
  1. 重新安装一个新的 apex,即 apex_no_distributed :
git clone https://github.com/ptrblck/apex.git
cd apex
git checkout apex_no_distributed
pip install -v --no-cache-dir ./

结果分别如下:
在这里插入图片描述
然而在实际使用时,AttributeError: module ‘torch.distributed‘ has no attribute ‘deprecated‘ 仍然存在,后来我注意到原文博客中torch版本为1.6.0,且github原文作者使用环境也为torch1.6.0。因此我怀疑原因可能是torch版本问题。于是我将现版本torch卸载安装1.7.0.最后重复操作。最后成功解决。

言外之语: nvidia的软件是真的难用,但凡碰到nVidia的问题基本就是些稀奇古怪的问题,软件安装过程就有一大堆问题,安装完成之后还会碰到一些稀奇古怪的问题,有的时候甚至按照GitHub上nVidia开发者的步骤(这个也想吐槽,安装过程前提条件一大堆,还说的语焉不详)来也是问题一大堆,经常安装不了。只能说以后写程序尽可能避开nVidia不然的话在不同电脑上兼容性就是一个大问题。

  • 22
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值