Chinese-LLaMA-Alpaca icon indicating copy to clipboard operation
Chinese-LLaMA-Alpaca copied to clipboard

如何根据不同的GPU显存来设置batch_size

Open heshuguo opened this issue 1 year ago • 4 comments

详细描述问题

我有三个nvidia Tesla的V100卡,1个16G,2个32G,该如何设置让这三个卡能够充分利用呢?不知道有没有大佬能够帮忙解答这个问题,试了好几次都没成功。现在最好的就是在2个32G的上面来跑,16G的就闲着用不了

heshuguo avatar May 11 '23 05:05 heshuguo

有一个做法是,采用pipeline并行,把模型拆成流水线放在不同的卡上,采用non-blocking方式实现的话,可以做到提高吞吐的能力,但是单条请求的latency可能会由于通信开销而增加一些

irasin avatar May 11 '23 06:05 irasin

pipeline并行 @irasin 感谢答复。 我们现在就是这种处理的,跑了一个进程,模型分到三个卡上,但是batch_size该怎么设置让不同的卡跑不同的batch_size?

heshuguo avatar May 11 '23 08:05 heshuguo

应该是跑三个进程,每个进程跑模型的不同部分,这样才能做成流水线。一个进程的话那就只能阻塞到整个请求推理完为止了。

irasin avatar May 11 '23 10:05 irasin

应该是跑三个进程,每个进程跑模型的不同部分,这样才能做成流水线。一个进程的话那就只能阻塞到整个请求推理完为止了。

@irasin 非常感谢回答。3个进程也尝试了,用torchrun这种方式,但是GPU显存三个占用基本上差不多,如果超过16G,就报OOM。怎么能最大限度利用各个GPU的显存,第一个16G,第二三个32G。

heshuguo avatar May 12 '23 00:05 heshuguo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your consideration.

github-actions[bot] avatar May 19 '23 22:05 github-actions[bot]

Closing the issue, since no updates observed. Feel free to re-open if you need any further assistance.

github-actions[bot] avatar May 23 '23 22:05 github-actions[bot]