AutoPercenty3/test_gpu_status.py

88 lines
2.8 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GPU 상태 확인 테스트 스크립트
사용법:
python test_gpu_status.py
"""
import sys
import os
import logging
# 모듈 경로 추가
sys.path.append('src')
from modules.gpu_status_checker import GPUStatusChecker
class TestLogger:
"""테스트용 간단한 로거"""
def log(self, msg, level=logging.INFO, exc_info=False):
level_names = {
logging.DEBUG: "DEBUG",
logging.INFO: "INFO",
logging.WARNING: "WARNING",
logging.ERROR: "ERROR"
}
print(f"[{level_names.get(level, 'INFO')}] {msg}")
if exc_info:
import traceback
traceback.print_exc()
def test_gpu_status():
"""GPU 상태 테스트"""
print("🎮 GPU 상태 확인 테스트 시작\n" + "="*50)
logger = TestLogger()
checker = GPUStatusChecker(logger=logger)
# 1. 전체 상태 확인
print("\n1⃣ 전체 GPU 구성요소 확인:")
status = checker.check_all_gpu_components()
# 2. 상태 보고서 출력
print("\n2⃣ 상태 보고서:")
report = checker.generate_status_report()
print(report)
# 3. cuDNN PATH 자동 설정 테스트
print("\n3⃣ cuDNN PATH 자동 설정 테스트:")
if status.get('cudnn', {}).get('installed', False):
print("cuDNN이 설치되어 있습니다. PATH 자동 설정을 테스트합니다...")
# 현재 PATH 확인
current_path = os.environ.get('PATH', '')
print(f"현재 PATH 길이: {len(current_path)} 문자")
# 자동 설정 시도
success = checker.auto_fix_cudnn_path()
print(f"자동 설정 결과: {'성공' if success else '실패'}")
# 설정 후 PATH 확인
new_path = os.environ.get('PATH', '')
print(f"설정 후 PATH 길이: {len(new_path)} 문자")
print(f"PATH 변경됨: {'' if len(new_path) != len(current_path) else '아니오'}")
# PATH 구성 재확인
path_status = checker._check_path_configuration()
print(f"PATH 설정 상태: {path_status.get('message', 'Unknown')}")
else:
print("cuDNN이 설치되지 않아 PATH 설정을 테스트할 수 없습니다.")
# 4. 권장사항 출력
recommendations = status.get('recommendations', [])
if recommendations:
print(f"\n4⃣ 권장사항 ({len(recommendations)}개):")
for i, rec in enumerate(recommendations, 1):
print(f" {i}. [{rec.get('priority', 'LOW').upper()}] {rec.get('action', 'Unknown')}")
print(f" {rec.get('description', '')}")
else:
print("\n4⃣ 🎉 모든 구성요소가 올바르게 설치되어 있습니다!")
print("\n" + "="*50 + "\n테스트 완료!")
if __name__ == "__main__":
test_gpu_status()