带nvidia apex库环境的搭建

搞了我好久,关键是nvcc和cuda版本要一致
对于我的3080,nvcc版本是11.0;对于我的2080,nvcc版本是10.0
以3080为例:

conda create -n PLOP python=3.7 -y
conda activate PLOP
#3080
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
#2080
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
pip install packaging
git clone https://github.com/NVIDIA/apex
cd apex

在安装之前,修改apex源码,把如下代码注释掉

if "reduce_scatter_tensor" not in dir(torch.distributed):
    torch.distributed.reduce_scatter_tensor = torch.distributed._reduce_scatter_base
if "all_gather_into_tensor" not in dir(torch.distributed):
    torch.distributed.all_gather_into_tensor = torch.distributed._all_gather_base

因为CUDA11.0不支持3080的8.6算力,所以需要修改

# 打开配置文件
vi ~/.bashrc
# 在配置文件中添加如下一行
export TORCH_CUDA_ARCH_LIST="8.0"  # 因为是CUDA11.0,对应的算力为8.0
# 保存后source更新
source ~/.bashrc

然后安装apex

pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

对于我要配置的PLOP环境,还需要再安装一些包

conda install tensorboardX
conda install matplotlib
pip install inplace-abn
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值