Baichuan2 icon indicating copy to clipboard operation
Baichuan2 copied to clipboard

多卡推理

Open shesung opened this issue 2 years ago • 10 comments
trafficstars

单卡部署13b-4bits 的模型经常 OOM(12 GB显存)。请问是否支持多卡推理?或者有什么简便的适配方案?

shesung avatar Sep 11 '23 12:09 shesung

支持多卡推理的,你from_pretrained的时候设置一下device_map=‘auto'试试

jameswu2014 avatar Sep 12 '23 02:09 jameswu2014

我试了一下,可以加载到两张卡上。但是,推理的速度非常慢,大概只有单卡的20%速度。并且很容易胡言乱语,或者出现inf,nan的报错。

shesung avatar Sep 12 '23 04:09 shesung

一样,单卡没问题,多卡必报错 6950587716fc6c29c49258d3e33e47a

AnitaSherry avatar Sep 12 '23 06:09 AnitaSherry

你的卡之间没有用pcie,驱动的问题,你试试,import torch a=torch.rand(2) a=a.to(”cuda:0") b=a.to("cuda:1") b输出如果都归零了,说明多卡之间的通信失败,会导致归零,需要改底层代码,卡之间传递的中间结果先转到cpu,再转到第二个卡。

tomcat123a avatar Sep 20 '23 21:09 tomcat123a

你的卡之间没有用pcie,驱动的问题,你试试,import torch a=torch.rand(2) a=a.to(”cuda:0") b=a.to("cuda:1") b输出如果都归零了,说明多卡之间的通信失败,会导致归零,需要改底层代码,卡之间传递的中间结果先转到cpu,再转到第二个卡。

试了下服务器上单机多卡,的确归零了。但是都插在PCIe上,请教下可能是什么原因造成呢?

xushenkun avatar Sep 24 '23 12:09 xushenkun

原因是没有禁用IOMMU.Linux下禁用之后(查chatgpt如何禁用)重启服务器。https://github.com/pytorch/pytorch/issues/84803

tomcat123a avatar Sep 25 '23 08:09 tomcat123a

@xushenkun @AnitaSherry 你们可以升级下显卡驱动。我这边2块4090,之前版本是525.53存在这个问题。现在升级到535.113已经解决了。

chenchun0629 avatar Oct 09 '23 01:10 chenchun0629

@chenchun0629 解决了

AnitaSherry avatar Oct 09 '23 03:10 AnitaSherry

AnitaSherry

是升级显卡版本解决的?

linxh91 avatar Dec 14 '23 14:12 linxh91

@AnitaSherry 怎么解决的?我的两块4090显卡也报这个错,一个显卡没问题。 NVIDIA-SMI 545.29.02 Driver Version: 545.29.02 CUDA Version: 12.3

phphappy avatar Dec 28 '23 04:12 phphappy