You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixed the bug related to saving DeepSpeed models. (#6628)
* Fixed the bug related to saving DeepSpeed models.
* Add information about training SD models using DeepSpeed to the README.
* Apply suggestions from code review
---------
Co-authored-by: mhh001 <[email protected]>
Co-authored-by: Sayak Paul <[email protected]>
Copy file name to clipboardExpand all lines: examples/text_to_image/README_sdxl.md
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -183,6 +183,66 @@ The above command will also run inference as fine-tuning progresses and log the
183
183
184
184
* SDXL's VAE is known to suffer from numerical instability issues. This is why we also expose a CLI argument namely `--pretrained_vae_model_name_or_path` that lets you specify the location of a better VAE (such as [this one](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix)).
185
185
186
+
187
+
### Using DeepSpeed
188
+
Using DeepSpeed one can reduce the consumption of GPU memory, enabling the training of models on GPUs with smaller memory sizes. DeepSpeed is capable of offloading model parameters to the machine's memory, or it can distribute parameters, gradients, and optimizer states across multiple GPUs. This allows for the training of larger models under the same hardware configuration.
189
+
190
+
First, you need to use the `accelerate config` command to choose to use DeepSpeed, or manually use the accelerate config file to set up DeepSpeed.
191
+
192
+
Here is an example of a config file for using DeepSpeed. For more detailed explanations of the configuration, you can refer to this [link](https://huggingface.co/docs/accelerate/usage_guides/deepspeed).
193
+
```yaml
194
+
compute_environment: LOCAL_MACHINE
195
+
debug: true
196
+
deepspeed_config:
197
+
gradient_accumulation_steps: 1
198
+
gradient_clipping: 1.0
199
+
offload_optimizer_device: none
200
+
offload_param_device: none
201
+
zero3_init_flag: false
202
+
zero_stage: 2
203
+
distributed_type: DEEPSPEED
204
+
downcast_bf16: 'no'
205
+
machine_rank: 0
206
+
main_training_function: main
207
+
mixed_precision: fp16
208
+
num_machines: 1
209
+
num_processes: 1
210
+
rdzv_backend: static
211
+
same_network: true
212
+
tpu_env: []
213
+
tpu_use_cluster: false
214
+
tpu_use_sudo: false
215
+
use_cpu: false
216
+
```
217
+
You need to save the mentioned configuration as an `accelerate_config.yaml` file. Then, you need to input the path of your `accelerate_config.yaml` file into the `ACCELERATE_CONFIG_FILE` parameter. This way you can use DeepSpeed to train your SDXL model in LoRA. Additionally, you can use DeepSpeed to train other SD models in this way.
0 commit comments