Skip to content

Commit 36e759c

Browse files
committed
fix: 抑制 xformers Triton 警告和调试日志
- 抑制 xformers 导入时的 Triton 警告信息 - 移除主题加载的调试日志
1 parent a07859f commit 36e759c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

desktop_qt_ui/main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,24 @@
2828
warnings.filterwarnings('ignore', message='.*Triton.*')
2929
warnings.filterwarnings('ignore', module='xformers')
3030

31+
# 抑制 xformers 导入时的 Triton 警告(这些是直接打印到 stdout 的)
32+
import io
33+
import contextlib
34+
35+
# 临时重定向 stdout 和 stderr 来抑制 xformers 的 Triton 警告
36+
_original_stdout = sys.stdout
37+
_original_stderr = sys.stderr
38+
sys.stdout = io.StringIO()
39+
sys.stderr = io.StringIO()
40+
3141
from PyQt6.QtWidgets import QApplication
3242
from main_window import MainWindow
3343
from services import init_services
3444

45+
# 恢复 stdout 和 stderr(xformers 已经导入完成)
46+
sys.stdout = _original_stdout
47+
sys.stderr = _original_stderr
48+
3549
def print_memory_snapshot():
3650
"""打印内存快照(前100行)"""
3751
snapshot = tracemalloc.take_snapshot()

desktop_qt_ui/main_window.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def _load_stylesheet(self):
102102

103103
# 获取主题设置,Pydantic会自动使用默认值'light'
104104
theme = config.app.theme
105-
print(f"[DEBUG] 加载主题: {theme}")
106105
self._apply_theme(theme)
107106

108107
def _apply_theme(self, theme: str):

0 commit comments

Comments
 (0)