Spaces:
Running
on
Zero
Running
on
Zero
lifeng
commited on
Commit
·
92bd220
1
Parent(s):
70ca38a
修改参数
Browse files
app.py
CHANGED
@@ -28,14 +28,14 @@ lora_base_path = "./models"
|
|
28 |
pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16)
|
29 |
transformer = FluxTransformer2DModel.from_pretrained(base_path, subfolder="transformer", torch_dtype=torch.bfloat16)
|
30 |
pipe.transformer = transformer
|
31 |
-
try:
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
except torch.cuda.OutOfMemoryError:
|
37 |
-
|
38 |
-
|
39 |
|
40 |
def clear_cache(transformer):
|
41 |
for name, attn_processor in transformer.attn_processors.items():
|
|
|
28 |
pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16)
|
29 |
transformer = FluxTransformer2DModel.from_pretrained(base_path, subfolder="transformer", torch_dtype=torch.bfloat16)
|
30 |
pipe.transformer = transformer
|
31 |
+
# try:
|
32 |
+
pipe.to("cuda")
|
33 |
+
# 在初始化模型后立即清理GPU缓存和启用注意力切片
|
34 |
+
# torch.cuda.empty_cache() # 清理GPU缓存
|
35 |
+
# pipe.enable_attention_slicing() # 启用注意力切片以减少内存使用
|
36 |
+
# except torch.cuda.OutOfMemoryError:
|
37 |
+
# print("CUDA out of memory. Switching to CPU.")
|
38 |
+
# pipe.to("cpu")
|
39 |
|
40 |
def clear_cache(transformer):
|
41 |
for name, attn_processor in transformer.attn_processors.items():
|