Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Lora微调训练的时候报错 #72

Open
4 of 5 tasks
wickedvalley opened this issue Jun 20, 2023 · 3 comments
Open
4 of 5 tasks

[Question] Lora微调训练的时候报错 #72

wickedvalley opened this issue Jun 20, 2023 · 3 comments
Labels
question Further information is requested

Comments

@wickedvalley
Copy link

Required prerequisites

Questions

Traceback (most recent call last):
File "/mnt/workspace/LLaMA-Efficient-Tuning/src/train_sft.py", line 97, in
main()
File "/mnt/workspace/LLaMA-Efficient-Tuning/src/train_sft.py", line 69, in main
train_result = trainer.train()
File "/home/pai/envs/llama_etuning/lib/python3.10/site-packages/transformers/trainer.py", line 1645, in train
return inner_training_loop(
File "/home/pai/envs/llama_etuning/lib/python3.10/site-packages/transformers/trainer.py", line 1987, in inner_training_loop
self.accelerator.clip_grad_norm
(
File "/home/pai/envs/llama_etuning/lib/python3.10/site-packages/accelerate/accelerator.py", line 1893, in clip_grad_norm_
self.unscale_gradients()
File "/home/pai/envs/llama_etuning/lib/python3.10/site-packages/accelerate/accelerator.py", line 1856, in unscale_gradients
self.scaler.unscale_(opt)
File "/home/pai/envs/llama_etuning/lib/python3.10/site-packages/torch/cuda/amp/grad_scaler.py", line 275, in unscale_
raise RuntimeError("unscale_() has already been called on this optimizer since the last update().")
RuntimeError: unscale_() has already been called on this optimizer since the last update().

Checklist

  • I have provided all relevant and necessary information above.
  • I have chosen a suitable title for this issue.
@wickedvalley wickedvalley added the question Further information is requested label Jun 20, 2023
@jiacheo
Copy link

jiacheo commented Jun 21, 2023

用 train_pt.py 也类似错误:

Traceback (most recent call last):
File "/mnt/workspace/LLaMA-Efficient-Tuning/src/train_pt.py", line 81, in
main()
File "/mnt/workspace/LLaMA-Efficient-Tuning/src/train_pt.py", line 53, in main
train_result = trainer.train()
File "/root/anaconda3/envs/baichuan-lora/lib/python3.10/site-packages/transformers/trainer.py", line 1645, in train
return inner_training_loop(
File "/root/anaconda3/envs/baichuan-lora/lib/python3.10/site-packages/transformers/trainer.py", line 1987, in inner_training_loop
self.accelerator.clip_grad_norm
(
File "/root/anaconda3/envs/baichuan-lora/lib/python3.10/site-packages/accelerate/accelerator.py", line 1893, in clip_grad_norm_
self.unscale_gradients()
File "/root/anaconda3/envs/baichuan-lora/lib/python3.10/site-packages/accelerate/accelerator.py", line 1856, in unscale_gradients
self.scaler.unscale_(opt)
File "/root/anaconda3/envs/baichuan-lora/lib/python3.10/site-packages/torch/cuda/amp/grad_scaler.py", line 275, in unscale_
raise RuntimeError("unscale_() has already been called on this optimizer since the last update().")
RuntimeError: unscale_() has already been called on this optimizer since the last update().
3%|███▎ | 1/30 [00:07<03:27, 7.17s/it]

@jiacheo
Copy link

jiacheo commented Jun 21, 2023

参考这篇: huggingface/transformers#24245 ,看样子是transformers某个版本的bug,换成评论里写的

!pip install git+https://github.com/huggingface/transformers@de9255de27abfcae4a1f816b904915f0b1e23cd9
就OK了。

@wickedvalley
Copy link
Author

换成指定的transformers==4.29.1就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants