Spaces:
Sleeping
Sleeping
fix: 修改设备选择逻辑,支持在没有 CUDA 的情况下使用 CPU
Browse files
app.py
CHANGED
@@ -68,12 +68,16 @@ class Demo:
|
|
68 |
|
69 |
self.training = False
|
70 |
self.generating = False
|
71 |
-
self.device = 'cuda'
|
72 |
self.weight_dtype = torch.bfloat16
|
73 |
self.model_sections = []
|
74 |
self.model_sections_count = gr.State(0)
|
75 |
|
76 |
model_id = 'stabilityai/stable-diffusion-xl-base-1.0'
|
|
|
|
|
|
|
|
|
|
|
77 |
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=self.weight_dtype).to(self.device)
|
78 |
pipe = None
|
79 |
del pipe
|
|
|
68 |
|
69 |
self.training = False
|
70 |
self.generating = False
|
|
|
71 |
self.weight_dtype = torch.bfloat16
|
72 |
self.model_sections = []
|
73 |
self.model_sections_count = gr.State(0)
|
74 |
|
75 |
model_id = 'stabilityai/stable-diffusion-xl-base-1.0'
|
76 |
+
if torch.cuda.is_available():
|
77 |
+
self.device = 'cuda'
|
78 |
+
else:
|
79 |
+
self.device = 'cpu'
|
80 |
+
|
81 |
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=self.weight_dtype).to(self.device)
|
82 |
pipe = None
|
83 |
del pipe
|