版本不匹配会报错:
RuntimeError: NCCL error in: /opt/conda/conda-bld/pytorch_1603729021865/work/torch/lib/c10d/ProcessGroupNCCL.cpp:784, invalid usage, NCCL version 2.7.8
barrier()
检查GPU的cuda版本是否匹配:nvidia-smi
在python环境中检查GPU是否可用:
import torch
print(torch.cuda.is_available())#true
print(torch.cuda.current_device())#no warning
torch.cuda.get_arch_list()#['sm_37', 'sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'compute_37'], rtx3090 needs sm_86
print(torch.cuda.device_count())
print(torch.cuda.get_device_name(0))
需要升级cudatoolkit版本到11.1及以上,相应的pytorch要用1.8.0及以上的。(python版本要3.6以上的,用的3.7的)
安装pytorch和cudatoolkit指令:Previous PyTorch Versions | PyTorch
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge;