what(): NCCL Error 1: unhandled cuda error解决方法

遇到问题

运行项目:ACL2021的一篇工作,LM-BFF (Better Few-shot Fine-tuning of Language Models) https://github.com/princeton-nlp/LM-BFF 遇到环境问题。
我的机器环境如下:

服务器上CUDA版本为11.4
GPU:4 x 24G 3090
虚拟环境用的python=3.6 
安装的pytorch的版本1.6.0(原项目中使用的版本,会报错)

产生如下报错

NCCL Error 1: unhandled cuda error

/home/lishizheng/anaconda3/envs/lmbff/lib/python3.6/site-packages/transformers/trainer.py:1096: FutureWarning: This method is deprecated, use `Trainer.is_local_process_zero()` instead.
  warnings.warn("This method is deprecated, use `Trainer.is_local_process_zero()` instead.", FutureWarning)
Epoch:   0%|                                                                                                                              | 0/250 [00:00<?, ?it/s]terminate called after throwing an instance of 'std::runtime_error'
  what():  NCCL Error 1: unhandled cuda error
Aborted (core dumped)

解决方法

这是pytorch 、cudatoolkit、cuda驱动的版本不一致导致的问题。
在这里插入图片描述

我的cuda版本是11.4,根据 CUDA版本11.4,pytorch应该下哪个版本的?,安装cudatoolkit为11.3,pytorch=1.10.2可用:

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

这样解决我的问题,代码可正常运行。

参考

[1] https://pytorch.org/get-started/previous-versions/

猜你喜欢

转载自blog.csdn.net/shizheng_Li/article/details/132582580