fasthardware 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fasthardware-1.0.0/PKG-INFO +12 -0
- fasthardware-1.0.0/fasthardware/__init__.py +0 -0
- fasthardware-1.0.0/fasthardware/fasthardware.py +102 -0
- fasthardware-1.0.0/fasthardware.egg-info/PKG-INFO +12 -0
- fasthardware-1.0.0/fasthardware.egg-info/SOURCES.txt +7 -0
- fasthardware-1.0.0/fasthardware.egg-info/dependency_links.txt +1 -0
- fasthardware-1.0.0/fasthardware.egg-info/top_level.txt +1 -0
- fasthardware-1.0.0/setup.cfg +4 -0
- fasthardware-1.0.0/setup.py +14 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fasthardware
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 범용 CPU/GPU 하드웨어 터보 가속 및 메모리 튜닝 라이브러리
|
|
5
|
+
Author: WoonGyo Choi & Gemini
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: classifier
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
File without changes
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import gc
|
|
4
|
+
import ctypes
|
|
5
|
+
import multiprocessing
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HardwareAccelerator:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.device_status = "UNKNOWN"
|
|
11
|
+
self.cpu_cores = multiprocessing.cpu_count()
|
|
12
|
+
|
|
13
|
+
def speedup(self, enable_gc_tuning=True, force_device=None):
|
|
14
|
+
"""
|
|
15
|
+
🚀 보스의 마법 소스: 어떤 프로그램이든 하드웨어 성능을 최대치로 땡겨오는 메서드
|
|
16
|
+
"""
|
|
17
|
+
print("\n" + "=" * 60)
|
|
18
|
+
print("⚡ [HARDWARE SPEEDUP ENGAGED] 시스템 가속 엔진 가동 시작...")
|
|
19
|
+
print("=" * 60)
|
|
20
|
+
|
|
21
|
+
# 1. 파이썬 내장 메모리 관리(GC) 가속 튜닝
|
|
22
|
+
if enable_gc_tuning:
|
|
23
|
+
gc.disable() # 무분별한 GC 개입으로 인한 프레임 드랍 원천 차단
|
|
24
|
+
print(f"⚙️ [메모리 최적화] 파이썬 내장 GC 비활성화 완료. (수동 고속 스위핑 전환)")
|
|
25
|
+
|
|
26
|
+
# 2. 하드웨어 환경 자동 탐색 및 가속 백엔드 매핑
|
|
27
|
+
detected_gpu = self._detect_gpu_hardware()
|
|
28
|
+
|
|
29
|
+
if force_device:
|
|
30
|
+
self.device_status = force_device
|
|
31
|
+
print(f"⚠️ [강제 설정] 보스의 요청에 의해 {force_device} 모드로 강제 구동합니다.")
|
|
32
|
+
else:
|
|
33
|
+
self.device_status = detected_gpu
|
|
34
|
+
|
|
35
|
+
# 3. 감지된 하드웨어별 특화 최적화 환경 주입
|
|
36
|
+
if self.device_status == "NVIDIA_CUDA":
|
|
37
|
+
self._engage_cuda_acceleration()
|
|
38
|
+
elif self.device_status == "INTEL_IGPU" or self.device_status == "OPENVINO":
|
|
39
|
+
self._engage_intel_acceleration()
|
|
40
|
+
else:
|
|
41
|
+
self._engage_cpu_vector_acceleration()
|
|
42
|
+
|
|
43
|
+
print(f"🔥 [가속 성공] 현재 시스템은 '{self.device_status}' 풀 파워 모드로 가동 중입니다.")
|
|
44
|
+
print("=" * 60 + "\n")
|
|
45
|
+
return self
|
|
46
|
+
|
|
47
|
+
def _detect_gpu_hardware(self):
|
|
48
|
+
""" 시스템 하드웨어를 다이렉트로 스캔하는 내부 매커니즘 """
|
|
49
|
+
# 1. NVIDIA CUDA 가능 여부 체크
|
|
50
|
+
try:
|
|
51
|
+
import torch
|
|
52
|
+
if torch.cuda.is_available():
|
|
53
|
+
return "NVIDIA_CUDA"
|
|
54
|
+
except ImportError:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
# 2. Intel OpenVINO 가속 장치 체크
|
|
58
|
+
try:
|
|
59
|
+
import openvino as ov
|
|
60
|
+
core = ov.Core()
|
|
61
|
+
if "GPU" in core.available_devices:
|
|
62
|
+
return "INTEL_IGPU"
|
|
63
|
+
except ImportError:
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
return "PURE_CPU"
|
|
67
|
+
|
|
68
|
+
def _engage_cuda_acceleration(self):
|
|
69
|
+
""" NVIDIA 외장 그래픽 카드가 있을 때 VRAM 전송 속도 및 스레드 최적화 """
|
|
70
|
+
print("🚀 [GPU 가속] NVIDIA CUDA 하드웨어 코어 감지! 고속 연산 스트림을 개방합니다.")
|
|
71
|
+
# 내부 프레임워크 튜닝 플래그 설정
|
|
72
|
+
os.environ["CUDA_MODULE_LOADING"] = "LAZY"
|
|
73
|
+
# OpenCV가 명시적으로 CUDA를 쓸 수 있도록 환경 매핑 (빌드 환경에 따라 작동)
|
|
74
|
+
os.environ["OPENCV_CUDA_USE_NVTX"] = "1"
|
|
75
|
+
|
|
76
|
+
def _engage_intel_acceleration(self):
|
|
77
|
+
""" 인텔 내장 GPU 또는 OpenVINO 파이프라인 최적화 레이턴시 주입 """
|
|
78
|
+
print("🚀 [GPU 가속] Intel iGPU / OpenVINO 가속 엔진 감지! 터보 레이턴시 힌트를 주입합니다.")
|
|
79
|
+
# 인텔 하드웨어 쓰루풋 최적화 플래그 고정
|
|
80
|
+
os.environ["OV_FRONTEND_CACHE_ENABLE"] = "1"
|
|
81
|
+
|
|
82
|
+
def _engage_cpu_vector_acceleration(self):
|
|
83
|
+
""" GPU가 없을 때, CPU의 모든 멀티코어를 100% 쥐어짜는 AVX2/OpenMP 강제 바인딩 """
|
|
84
|
+
print(f"💻 [CPU 최적화] 전용 GPU 미감지. 물리 코어 {self.cpu_cores}개 전체에 고속 벡터 연산(SIMD)을 명령합니다.")
|
|
85
|
+
|
|
86
|
+
# MKL, OpenBLAS 등 파이썬 내부 행렬 연산 라이브러리가 CPU 멀티코어를 풀로 쓰도록 강제 세팅
|
|
87
|
+
threads_str = str(self.cpu_cores)
|
|
88
|
+
os.environ["OMP_NUM_THREADS"] = threads_str
|
|
89
|
+
os.environ["MKL_NUM_THREADS"] = threads_str
|
|
90
|
+
os.environ["OPENBLAS_NUM_THREADS"] = threads_str
|
|
91
|
+
os.environ["VECLIB_MAXIMUM_THREADS"] = threads_str
|
|
92
|
+
os.environ["NUMEXPR_NUM_THREADS"] = threads_str
|
|
93
|
+
|
|
94
|
+
def manual_sweep(self):
|
|
95
|
+
""" 프로그램 루프 안에서 팅김을 방지하기 위해 보스가 원할 때 수동으로 메모리를 초고속 청소하는 메서드 """
|
|
96
|
+
gc.collect()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# 외부에서 그냥 "import hardware" 후 바로 쓸 수 있도록 싱글톤 인스턴스 미리 생성
|
|
100
|
+
_accelerator = HardwareAccelerator()
|
|
101
|
+
speedup = _accelerator.speedup
|
|
102
|
+
manual_sweep = _accelerator.manual_sweep
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fasthardware
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 범용 CPU/GPU 하드웨어 터보 가속 및 메모리 튜닝 라이브러리
|
|
5
|
+
Author: WoonGyo Choi & Gemini
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: classifier
|
|
11
|
+
Dynamic: requires-python
|
|
12
|
+
Dynamic: summary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fasthardware
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="fasthardware", # 🔑 pip install 할 패키지 이름
|
|
5
|
+
version="1.0.0", # 보스 가속 엔진의 기념비적인 첫 버전!
|
|
6
|
+
author="WoonGyo Choi & Gemini", # 공동 개발자 명시
|
|
7
|
+
description="범용 CPU/GPU 하드웨어 터보 가속 및 메모리 튜닝 라이브러리",
|
|
8
|
+
packages=find_packages(), # fasthardware 폴더를 자동으로 패키지화
|
|
9
|
+
classifiers=[
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"License :: OSI Approved :: MIT License",
|
|
12
|
+
],
|
|
13
|
+
python_requires=">=3.8",
|
|
14
|
+
)
|