FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

训练bge-reranker-large时,加入参数--gradient_checkpointing 后报错

Open dadyita opened this issue 2 years ago • 1 comments

命令行如下 #!/bin/sh CUDA_VISIBLE_DEVICES=3
torchrun --nproc_per_node 1
-m FlagEmbedding.reranker.run
--output_dir /home/dayita/model/rerank/train3
--model_name_or_path /llms/models/bge-reranker-large/
--train_data /home/dayita/muyu/testForRerank2.jsonl
--learning_rate 1e-5
--gradient_checkpointing
--fp16
--num_train_epochs 5
--per_device_train_batch_size 3
--gradient_accumulation_steps 4
--dataloader_drop_last True
--train_group_size 5
--max_len 512
--weight_decay 0.01
--logging_steps 10

报错信息如下:RuntimeError: Expected to mark a variable ready only once. This error is caused by one of the following reasons: 1) Use of a module parameter outside the forward function. Please make sure model parameters are not shared across multiple concurrent forward-backward passes. or try to use _set_static_graph() as a workaround if this module graph does not change during training loop.2) Reused parameters in multiple reentrant backward passes. For example, if you use multiple checkpoint functions to wrap the same part of your model, it would result in the same set of parameters been used by different reentrant backward passes multiple times, and hence marking a variable ready multiple times. DDP does not support such use cases in default. You can try to use _set_static_graph() as a workaround if your module graph does not change over iterations. Parameter at index 387 has been marked as ready twice. This means that multiple autograd engine hooks have fired for this particular parameter during this iteration. You can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print parameter names for further debugging.

dadyita avatar Nov 22 '23 06:11 dadyita

--gradient_checkpointing 需要在开启deepspeed的情况下使用

staoxiao avatar Nov 22 '23 11:11 staoxiao