LLM-Tuning icon indicating copy to clipboard operation
LLM-Tuning copied to clipboard

多卡训练感觉不是并发的?

Open shenmadouyaowen opened this issue 2 years ago • 8 comments

看了一下GPU的使用率,是一个个跳100%的,你们有没有这种情况?

shenmadouyaowen avatar Jun 30 '23 03:06 shenmadouyaowen

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。

如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

beyondguo avatar Jun 30 '23 06:06 beyondguo

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。

如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

好的,谢谢大佬

shenmadouyaowen avatar Jun 30 '23 06:06 shenmadouyaowen

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。

如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

你好,我使用model parallel训练,训练了29step就卡住了,gpu运行0%,cpu运行100%。请问这种情况你碰到过吗?

SunyanGu avatar Jun 30 '23 08:06 SunyanGu

暂时没碰到。有什么报错吗

beyondguo avatar Jun 30 '23 12:06 beyondguo

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。 如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

你好,我使用model parallel训练,训练了29step就卡住了,gpu运行0%,cpu运行100%。请问这种情况你碰到过吗?

通常训练到一半中道崩猝的都是因为内存/显存啥的不够,缩小batch size,gradient accumulate等参数再试试?

yizhuoliang avatar Jul 02 '23 21:07 yizhuoliang

暂时没碰到。有什么报错吗

没有报错,目前来看应该是data_collator有问题,因为chatglm可以正常跑,百川用的DataCollatorForLanguageModeling会卡住。我用的是V100。

SunyanGu avatar Jul 03 '23 02:07 SunyanGu

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。 如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

你好,我使用model parallel训练,训练了29step就卡住了,gpu运行0%,cpu运行100%。请问这种情况你碰到过吗?

通常训练到一半中道崩猝的都是因为内存/显存啥的不够,缩小batch size,gradient accumulate等参数再试试?

缩小batch没有用,应该是数据load问题

SunyanGu avatar Jul 03 '23 02:07 SunyanGu

正常的,因为目前代码里设置的是 device_map="auto",在多卡状态下会自动触发 model parallel 模型并行,就是把模型的多个层分配到不同的 GPU 上,从而可以节省显存、加大batch。我自己测的时候,发现它会比 data parallel 更快。 如果想改成 data parallel,则将 device_map="auto" 改为:device_map={'':torch.cuda.current_device()}

你好,我使用model parallel训练,训练了29step就卡住了,gpu运行0%,cpu运行100%。请问这种情况你碰到过吗?

你好,我训练baichuan的时候也遇到了这个问题,训练卡住了,但显存仍然占用着

TransformersWsz avatar Oct 25 '23 05:10 TransformersWsz