wjs0725 commited on
Commit
d73cf56
1 Parent(s): 70ee58a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -25,16 +25,17 @@ login(token=os.getenv('Token'))
25
 
26
  import torch
27
 
28
- device = torch.cuda.current_device()
29
- print("!!!!!!!!!!!!device!!!!!!!!!!!!!!",device)
30
- total_memory = torch.cuda.get_device_properties(device).total_memory
31
- allocated_memory = torch.cuda.memory_allocated(device)
32
- reserved_memory = torch.cuda.memory_reserved(device)
33
 
34
- print(f"Total memory: {total_memory / 1024**2:.2f} MB")
35
- print(f"Allocated memory: {allocated_memory / 1024**2:.2f} MB")
36
- print(f"Reserved memory: {reserved_memory / 1024**2:.2f} MB")
37
 
 
38
  name = 'flux-dev'
39
  ae = load_ae(name, device)
40
  t5 = load_t5(device, max_length=256 if name == "flux-schnell" else 512)
@@ -129,14 +130,14 @@ def edit(init_image, source_prompt, target_prompt, num_steps, inject_step, guida
129
  print("!!!!!!!!self.clip!!!!!!",next(clip.parameters()).device)
130
  print("!!!!!!!!self.model!!!!!!",next(model.parameters()).device)
131
 
132
- device = torch.cuda.current_device()
133
- total_memory = torch.cuda.get_device_properties(device).total_memory
134
- allocated_memory = torch.cuda.memory_allocated(device)
135
- reserved_memory = torch.cuda.memory_reserved(device)
136
 
137
- print(f"Total memory: {total_memory / 1024**2:.2f} MB")
138
- print(f"Allocated memory: {allocated_memory / 1024**2:.2f} MB")
139
- print(f"Reserved memory: {reserved_memory / 1024**2:.2f} MB")
140
 
141
  with torch.no_grad():
142
  inp = prepare(t5, clip, init_image, prompt=opts.source_prompt)
 
25
 
26
  import torch
27
 
28
+ # device = torch.cuda.current_device()
29
+ # print("!!!!!!!!!!!!device!!!!!!!!!!!!!!",device)
30
+ # total_memory = torch.cuda.get_device_properties(device).total_memory
31
+ # allocated_memory = torch.cuda.memory_allocated(device)
32
+ # reserved_memory = torch.cuda.memory_reserved(device)
33
 
34
+ # print(f"Total memory: {total_memory / 1024**2:.2f} MB")
35
+ # print(f"Allocated memory: {allocated_memory / 1024**2:.2f} MB")
36
+ # print(f"Reserved memory: {reserved_memory / 1024**2:.2f} MB")
37
 
38
+ device = "cuda" if torch.cuda.is_available() else "cpu"
39
  name = 'flux-dev'
40
  ae = load_ae(name, device)
41
  t5 = load_t5(device, max_length=256 if name == "flux-schnell" else 512)
 
130
  print("!!!!!!!!self.clip!!!!!!",next(clip.parameters()).device)
131
  print("!!!!!!!!self.model!!!!!!",next(model.parameters()).device)
132
 
133
+ # device = torch.cuda.current_device()
134
+ # total_memory = torch.cuda.get_device_properties(device).total_memory
135
+ # allocated_memory = torch.cuda.memory_allocated(device)
136
+ # reserved_memory = torch.cuda.memory_reserved(device)
137
 
138
+ # print(f"Total memory: {total_memory / 1024**2:.2f} MB")
139
+ # print(f"Allocated memory: {allocated_memory / 1024**2:.2f} MB")
140
+ # print(f"Reserved memory: {reserved_memory / 1024**2:.2f} MB")
141
 
142
  with torch.no_grad():
143
  inp = prepare(t5, clip, init_image, prompt=opts.source_prompt)