BlinkDL / RWKV-LM

RWKV is an RNN with transformer-level LLM performance. It can be directly trained like a GPT (parallelizable). So it's combining the best of RNN and transformer - great performance, fast inference, saves VRAM, fast training, "infinite" ctx_len, and free sentence embedding.
Apache License 2.0
12.05k stars 827 forks source link

其它的都非常好,现在有个问题就是多卡怎么并连成单卡 #146

Closed gg22mm closed 1 year ago

gg22mm commented 1 year ago

其它的都非常好,现在有个问题就是多卡怎么合成像单卡那样用来训练?

我试的时候 3B是可以的,7B就不行。

比如我用一张 A100 80G 全量训练7B,报显存不足,再给它一张也是一样报不显存不足。 按道理来说两个卡总的显存叠加的话是够了的,但是 - 它还是以单卡显存进行验证所以导致报显存不足, 最终启动不了。


我尝试过修复:

单机多卡 trainer = Trainer(gpus=2, strategy="dp") #不行 trainer = Trainer(gpus=[0, 1], strategy="dp") #这种方式也不行 trainer = Trainer(devices=2, accelerator="gpu") #也不行

难道我只能等到以后英伟达出单卡几百G的那种,我才能运行起来吗?

不知道大佬是怎么弄的。感谢指点~~

BlinkDL commented 1 year ago

用v4neo/train.py训练

junfengP commented 1 year ago

我也遇到这个问题,使用v4neo/train.py训练,4张A100(40G)。代码看起来默认是做数据并行的,启动会报CUDA OOM

python train.py \
    --load_model "/root/rwkv/model/RWKV-4-Raven-7B-v12-Eng49%-Chn49%-Jpn1%-Other1%-20230530-ctx8192.pth" \
    --proj_dir "/root/rwkv/model/tuned" \
    --data_file "/root/rwkv/data/qa_text_document" \
    --data_type binidx \
    --vocab_size 50277 \
    --ctx_len 1024 \
    --accumulate_grad_batches 1 \
    --epoch_steps 200 \
    --epoch_count 10 \
    --epoch_begin 0 \
    --epoch_save 2 \
    --micro_bsz 1 \
    --n_layer 32 \
    --n_embd 4096 \
    --pre_ffn 0 \
    --head_qk 0 \
    --lr_init 1e-5 \
    --lr_final 1e-5 \
    --warmup_steps 50 \
    --beta1 0.9 \
    --beta2 0.999 \
    --adam_eps 1e-8 \
    --accelerator gpu \
    --devices 1 \
    --precision fp16 \
    --strategy deepspeed_stage_2 \
    --grad_cp 1
gg22mm commented 1 year ago

用v4neo/train.py训练

现在不管是用哪个都有这个情况~~,不知道有什么好的解决办法。

我也查了目前市面上的的方案,大多都是 说的“多卡”不是真的“多卡”,前提都是基于单卡显存可以启动的情况才能使用的多卡(崩溃在在这里,如果单卡都能启动,我还用多卡干吗,脱裤子放屁的感觉)。反之启动都启动不了。 没有任何意义。

当显存不足时,如何用 DeepSpeed+内存/或是用多张卡来启动? 这个才是关键,主要能启动。 我查了相关资料,其实最后都是没有解决。

还专门看了些报错的如: https://github.com/Lightning-AI/lightning/issues/16298#issuecomment-1456569610 https://github.com/Lightning-AI/lightning/pull/16973 https://github.com/Lightning-AI/lightning/issues/16117

之前见别人用过accelerate是可以的: pip install accelerate
https://www.kaggle.com/code/evilpsycho42/pytorch-multi-gpus-train-infer

就是不知道怎么整合进去