Open billvsme opened 8 months ago
A better way would be to assign args.mixed_precision
from accelerator.mixed_precision
.
However, when you initialize an Accelerator
object you pass the value from args.mixed_precision
itself:
So, passing mixed_precision
to your CLI args is recommended.
@sayakpaul 👌,thanks
But I found one that was different from train_text_to_image.py and train_text_to_image_lora.py, train_text_to_image_lora.py didn't reassign the args.mixed_precision. In this way, if you specify accelerate launch --mixed_precision="fp16"
in the accelerator, you need to add the same --mixed_precision="fp16" to the CLI args . Only in this way will there be no error, like is
accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \
--mixed_precision="fp16" \
......
train_text_to_image.py: https://github.com/huggingface/diffusers/blob/1fff527702399165f09dd880be43cfd8b8bae472/examples/text_to_image/train_text_to_image.py#L811-L816
train_text_to_image_lora.py: https://github.com/huggingface/diffusers/blob/1fff527702399165f09dd880be43cfd8b8bae472/examples/text_to_image/train_text_to_image_lora.py#L444-L448
Maybe the example in the docs needs to be updated
https://github.com/huggingface/diffusers/tree/main/examples/text_to_image
Should be fixed with: https://github.com/huggingface/diffusers/issues/6388. Could you pull the changes and try again? :)
Hi @sayakpaul , The problem with running train_text_to_image_lora.py still persists for me. I have pulled the latest changes from the GitHub repo.
Could you maybe refer to https://github.com/huggingface/diffusers/issues/6552 and open a PR?
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
can we close this one now?
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
I encountered the same issue on diffusers==0.30.0.dev0. The additional CLI args works on this version as well.
Just encountered this issue. Not stale.
Describe the bug
When looking at the examples/text_to_image documentation, I experimented with the train_text_to_image_lora.py following the examples in the documentation. But I found that the run with
raise ValueError("Attempting to unscale FP16 gradients.")
error.I found that the cause of the error may be related to this code. Here use args.mixed_precision to determine whether to convert Lora's parameters to float32, but args.mixed_precision default value is None, according to the example in README, the mixedprecision of accelerate is set, and it is not set args.mixed precision, so it causes "Attempting to unscale FP16 gradients." error. https://github.com/huggingface/diffusers/blob/1fff527702399165f09dd880be43cfd8b8bae472/examples/text_to_image/train_text_to_image_lora.py#L468-L472
It might be a better choice to change this to use
accelerator.mixed_precision
Reproduction
Logs
System Info
diffusers
version: 0.25.0.dev0Who can help?
@sayakpaul