Spaces:
Paused
Paused
Fix string formatting in Blender script template
Browse files- Changed f-strings to string concatenation in GPU config section
- Fixes KeyError: 'compute_device_type' in .format() call
- Aligns with demo.zip coding style (string concatenation, not f-strings)
- Lines 374, 382, 384: Removed f-string syntax to avoid format() conflicts
code/cube3d/render/render_bricks_safe.py
CHANGED
|
@@ -371,7 +371,7 @@ try:
|
|
| 371 |
if device['name'].startswith(('NVIDIA', 'Apple', 'AMD')):
|
| 372 |
device['use'] = 1
|
| 373 |
gpu_used = True
|
| 374 |
-
print(
|
| 375 |
else:
|
| 376 |
device['use'] = 0
|
| 377 |
if not gpu_used:
|
|
@@ -379,9 +379,9 @@ try:
|
|
| 379 |
scene.cycles.device = 'CPU'
|
| 380 |
print("ℹ️ 使用 CPU 渲染(samples=512)")
|
| 381 |
else:
|
| 382 |
-
print(
|
| 383 |
except Exception as gpu_error:
|
| 384 |
-
print(
|
| 385 |
print("ℹ️ 回退到 CPU 渲染(samples=512)")
|
| 386 |
scene.cycles.device = 'CPU'
|
| 387 |
|
|
|
|
| 371 |
if device['name'].startswith(('NVIDIA', 'Apple', 'AMD')):
|
| 372 |
device['use'] = 1
|
| 373 |
gpu_used = True
|
| 374 |
+
print("✅ 启用 GPU: " + device['name'])
|
| 375 |
else:
|
| 376 |
device['use'] = 0
|
| 377 |
if not gpu_used:
|
|
|
|
| 379 |
scene.cycles.device = 'CPU'
|
| 380 |
print("ℹ️ 使用 CPU 渲染(samples=512)")
|
| 381 |
else:
|
| 382 |
+
print("ℹ️ 使用 GPU 渲染(" + compute_device_type + ", samples=512)")
|
| 383 |
except Exception as gpu_error:
|
| 384 |
+
print("⚠️ GPU 初始化失败: " + str(gpu_error))
|
| 385 |
print("ℹ️ 回退到 CPU 渲染(samples=512)")
|
| 386 |
scene.cycles.device = 'CPU'
|
| 387 |
|