chatglm_tuning icon indicating copy to clipboard operation
chatglm_tuning copied to clipboard

多卡训练占用显存

Open nilin1998 opened this issue 2 years ago • 1 comments

我在精度为fp16的情况下,单卡微调训练占用16G显存,使用多卡训练,则需要两个16G显存,但我的理解中,多卡训练时,所需的16G显存平均分到每张卡上,每张卡只占用8G显存。请问问题出在哪里了呢 单卡:image

多卡:image

nilin1998 avatar Jun 05 '23 07:06 nilin1998

多卡训练一般指的是数据并行,每张卡上会有一个 batch 的数据在训练,所以每张卡上都会占用 16g 显存。假设有两个卡,多卡训练的好处是其真实的 batch_size 是单卡的2倍,所以总训练步数会减半,训练时间减少

zejunwang1 avatar Jun 05 '23 23:06 zejunwang1