fffiloni commited on
Commit
032504d
β€’
1 Parent(s): 6debf2b

ensuring GPU is auto stopped after 5 minutes when finished

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -141,6 +141,8 @@ def train_dreambooth_lora_sdxl(dataset_id, instance_data_dir, lora_trained_xl_fo
141
  print("Training is finished!")
142
  if remove_gpu:
143
  swap_hardware(hf_token, "cpu-basic")
 
 
144
  except subprocess.CalledProcessError as e:
145
  print(f"An error occurred: {e}")
146
 
@@ -154,6 +156,8 @@ def train_dreambooth_lora_sdxl(dataset_id, instance_data_dir, lora_trained_xl_fo
154
  '''
155
  if remove_gpu:
156
  swap_hardware(hf_token, "cpu-basic")
 
 
157
  #write_to_community(title,description,hf_token)
158
 
159
  def main(dataset_id,
@@ -351,7 +355,7 @@ with gr.Blocks(css=css) as demo:
351
  max_train_steps = gr.Number(label="Max Training Steps", value=500, precision=0, step=10)
352
  checkpoint_steps = gr.Number(label="Checkpoints Steps", value=100, precision=0, step=10)
353
 
354
- remove_gpu = gr.Checkbox(label="Remove GPU After Training", value=True)
355
  train_button = gr.Button("Train !")
356
 
357
  train_status = gr.Textbox(label="Training status")
@@ -381,4 +385,4 @@ with gr.Blocks(css=css) as demo:
381
  outputs = [train_status]
382
  )
383
 
384
- demo.queue(default_enabled=False).launch(debug=True)
 
141
  print("Training is finished!")
142
  if remove_gpu:
143
  swap_hardware(hf_token, "cpu-basic")
144
+ else:
145
+ swap_sleep_time(hf_token, 300)
146
  except subprocess.CalledProcessError as e:
147
  print(f"An error occurred: {e}")
148
 
 
156
  '''
157
  if remove_gpu:
158
  swap_hardware(hf_token, "cpu-basic")
159
+ else:
160
+ swap_sleep_time(hf_token, 300)
161
  #write_to_community(title,description,hf_token)
162
 
163
  def main(dataset_id,
 
355
  max_train_steps = gr.Number(label="Max Training Steps", value=500, precision=0, step=10)
356
  checkpoint_steps = gr.Number(label="Checkpoints Steps", value=100, precision=0, step=10)
357
 
358
+ remove_gpu = gr.Checkbox(label="Remove GPU After Training", value=True, info="If NOT enabled, don't forget to remove the GPU attribution after you are done.")
359
  train_button = gr.Button("Train !")
360
 
361
  train_status = gr.Textbox(label="Training status")
 
385
  outputs = [train_status]
386
  )
387
 
388
+ demo.launch(debug=True)