fasthardware 2.0.3__tar.gz → 2.2.2__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.
Files changed (27) hide show
  1. fasthardware-2.2.2/PKG-INFO +18 -0
  2. fasthardware-2.2.2/README.md +52 -0
  3. {fasthardware-2.0.3 → fasthardware-2.2.2}/autopublish/publisher.py +1 -0
  4. fasthardware-2.2.2/cy_yologic/__init__.py +2 -0
  5. fasthardware-2.2.2/fasthardware/__init__.py +14 -0
  6. fasthardware-2.2.2/fasthardware/fasthardware.py +211 -0
  7. fasthardware-2.2.2/fasthardware.egg-info/PKG-INFO +18 -0
  8. {fasthardware-2.0.3 → fasthardware-2.2.2}/fasthardware.egg-info/SOURCES.txt +4 -3
  9. fasthardware-2.2.2/fasthardware.egg-info/requires.txt +5 -0
  10. {fasthardware-2.0.3 → fasthardware-2.2.2}/fasthardware.egg-info/top_level.txt +2 -1
  11. fasthardware-2.2.2/setup.py +25 -0
  12. fasthardware-2.2.2/ungyoseries/__init__.py +9 -0
  13. fasthardware-2.2.2/ungyoseries/hython.py +41 -0
  14. fasthardware-2.0.3/PKG-INFO +0 -104
  15. fasthardware-2.0.3/README.md +0 -80
  16. fasthardware-2.0.3/easy-path/easy-path1.py +0 -68
  17. fasthardware-2.0.3/fasthardware/__init__.py +0 -2
  18. fasthardware-2.0.3/fasthardware/fasthardware.py +0 -78
  19. fasthardware-2.0.3/fasthardware.egg-info/PKG-INFO +0 -104
  20. fasthardware-2.0.3/fasthardware.egg-info/requires.txt +0 -1
  21. fasthardware-2.0.3/package_guardian/__init__.py +0 -0
  22. fasthardware-2.0.3/setup.py +0 -38
  23. {fasthardware-2.0.3 → fasthardware-2.2.2}/autopublish/__init__.py +0 -0
  24. {fasthardware-2.0.3 → fasthardware-2.2.2}/fasthardware.egg-info/dependency_links.txt +0 -0
  25. {fasthardware-2.0.3/easy-path → fasthardware-2.2.2/package_guardian}/__init__.py +0 -0
  26. {fasthardware-2.0.3 → fasthardware-2.2.2}/package_guardian/guardian1.py +0 -0
  27. {fasthardware-2.0.3 → fasthardware-2.2.2}/setup.cfg +0 -0
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: fasthardware
3
+ Version: 2.2.2
4
+ Summary: Hyper-Performance Environment Setup for AI & Hardware Accelerating
5
+ Author: ungyo
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: numpy>=1.20.0
10
+ Requires-Dist: aiohttp>=3.8.0
11
+ Requires-Dist: requests>=2.25.0
12
+ Requires-Dist: openvino>=2023.0.0
13
+ Requires-Dist: opencv-python>=4.5.0
14
+ Dynamic: author
15
+ Dynamic: classifier
16
+ Dynamic: requires-dist
17
+ Dynamic: requires-python
18
+ Dynamic: summary
@@ -0,0 +1,52 @@
1
+ Markdown
2
+ # 🚀 ungyoseries
3
+
4
+ `hython` is a hyper-performance optimization framework designed to break through Python's runtime limitations and extract 100% of the underlying hardware potential.
5
+
6
+ By seamlessly integrating with `fasthardware V2`, the low-level system tuning engine, `hython` allows you to manage OS scheduler preemption, OpenVINO iGPU cache synchronization, and OpenCV SIMD acceleration with just a single line of code.
7
+
8
+ ---
9
+
10
+ ## 🛠️ Core Features
11
+
12
+ 1. **`fasthardware` Backbone**: Native integration with the core hardware acceleration module as a strict dependency, guaranteeing an optimized execution layer.
13
+ 2. **OS Process Preemption**: Dynamically elevates the process priority to the highest tier (`HIGH_PRIORITY_CLASS` on Windows / `NICE -20` on Linux) and binds child processes to dedicated CPU cores (`ULTIMATE` mode) to eliminate context-switching overhead.
14
+ 3. **OpenVINO Singleton Acceleration**: Synchronizes the core instance to leverage the Intel iGPU `LATENCY` optimization hint and handles model caching to eliminate initial compilation delays.
15
+ 4. **Intelligent GC Scheduling**: Suppresses the background Python Garbage Collector during execution to wipe out frame drops (stuttering), while executing low-level virtual memory working set flushes via `manual_sweep()` right at the function exit.
16
+ 5. **Built-in Aliasing**: Exposes direct access to high-speed computation modules like `hython.np` and the engine `hython.fasthardware` out of the box.
17
+
18
+ ---
19
+
20
+ ## 📦 Local Developer Installation
21
+
22
+ Open your terminal in the project's root directory and run the following commands to perform a clean build and forced update:
23
+
24
+ ```bash
25
+ # 1. Clean previous build caches and metadata
26
+ rmdir /s /q build dist hython.egg-info
27
+
28
+ # 2. Re-install in editable mode based on the verified setup.py
29
+ python setup.py sdist bdist_wheel
30
+ pip install --upgrade -e .
31
+ 💻 Usage
32
+ Global Initialization and Pipeline Wrapping
33
+ Call init exactly once when the main script boots to configure the system environment, and wrap your real-time processing loop with the @hython.boost() decorator to prevent memory leaks and frame jitter.
34
+
35
+ Python
36
+ from ungyoseries import hython
37
+
38
+ # 1. Initialize global hardware tuning (ULTIMATE mode recruits all child processes)
39
+ hython.init(mode="ULTIMATE")
40
+
41
+ # 2. Decorate the pipeline for frame-drop protection and automatic memory overhaul
42
+ @hython.boost()
43
+ def my_heavy_pipeline():
44
+ # Directly access high-speed libraries embedded in hython
45
+ large_matrix = hython.np.ones(50000000)
46
+ print("🚀 Hyper-performance real-time inference pipeline is active.")
47
+
48
+ # Explicitly invoke a low-level working set flush inside the loop if necessary
49
+ hython.fasthardware.manual_sweep()
50
+
51
+ if __name__ == "__main__":
52
+ my_heavy_pipeline()
@@ -21,6 +21,7 @@ def deploy():
21
21
  if not pypi_token:
22
22
  print("❌ ERROR: Environment variable 'PYPI_TOKEN' is missing.")
23
23
  print("💡 Action: Set your token in the terminal first:")
24
+ pypi_token = input()
24
25
  print(" Windows (PowerShell): $env:PYPI_TOKEN='pypi-your-token-here'")
25
26
  return
26
27
 
@@ -0,0 +1,2 @@
1
+ # __init__.py
2
+ from .cy_yologic import get_spine_angle_fast, check_immobile_fast
@@ -0,0 +1,14 @@
1
+ # 옆에 있는 fasthardware.py 모듈을 패키지 루트로 끌어올립니다.
2
+ # ungyoseries/fasthardware/__init__.py
3
+ from .fasthardware import speedup, get_core, manual_sweep, FastVideoStream
4
+
5
+ # 💡 웅요님이 설계하신 대로!
6
+ # 시스템 튜닝 함수들은 fasthardware 모듈의 직계 자식으로 바로 노출합니다.
7
+ # ex) fasthardware.speedup(), fasthardware.FastVideoStream()
8
+
9
+ __all__ = [
10
+ 'speedup',
11
+ 'get_core',
12
+ 'manual_sweep',
13
+ 'FastVideoStream',
14
+ ]
@@ -0,0 +1,211 @@
1
+ import os
2
+ import sys
3
+ import psutil
4
+ import gc
5
+ import ctypes
6
+ import platform
7
+ import cv2
8
+ import threading
9
+ import numpy as np
10
+
11
+ _current_process = psutil.Process(os.getpid())
12
+ _ov_core = None # 싱글톤 OpenVINO core
13
+
14
+
15
+ # ─────────────────────────────────────────
16
+ # 🚀 웅요님의 최고 성능 완제품 비디오 스트림 엔진
17
+ # ─────────────────────────────────────────
18
+ class FastVideoStream:
19
+ def __init__(self, src=0):
20
+ # 윈도우 환경 최적화(CAP_DSHOW) 및 해상도, 버퍼 최소화 고정 세팅
21
+ self.cap = cv2.VideoCapture(src, cv2.CAP_DSHOW)
22
+ self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
23
+ self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
24
+ self.cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
25
+
26
+ self.ret, self.frame = self.cap.read()
27
+ self.latest_frame = self.frame.copy() if self.ret else np.zeros((480, 640, 3), dtype=np.uint8)
28
+ self.started = False
29
+
30
+ def start(self):
31
+ """백그라운드 쓰레드로 스트림 상시 가동"""
32
+ if self.started:
33
+ return self
34
+ self.started = True
35
+ threading.Thread(target=self.update, daemon=True).start()
36
+ return self
37
+
38
+ def update(self):
39
+ """GIL 보호 영역에서 최신 프레임 무한 갱신 (OpenCV 렉 원천 차단)"""
40
+ while self.started:
41
+ ret, frame = self.cap.read()
42
+ if ret:
43
+ self.latest_frame = frame
44
+
45
+ def read(self):
46
+ """지연 시간이 '0'에 수렴하는 가장 최신의 프레임 반환"""
47
+ return self.latest_frame
48
+
49
+ def stop(self):
50
+ """스트림 종료 및 하드웨어 가속 리소스 해제"""
51
+ self.started = False
52
+ if self.cap.isOpened():
53
+ self.cap.release()
54
+
55
+
56
+ # ─────────────────────────────────────────
57
+ # ⚡ 하드웨어 가속 런타임 튜닝 핵심 함수들
58
+ # ─────────────────────────────────────────
59
+ def speedup(mode="DEFAULT"):
60
+ print(f"\n [FASTHARDWARE V2] Tuning mode: {mode}...")
61
+
62
+ _elevate_priority(_current_process)
63
+ _optimize_runtime()
64
+ _bind_c_libraries()
65
+ _accelerate_inference()
66
+
67
+ if mode == "ULTIMATE":
68
+ _supercharge_children()
69
+
70
+ print(" [FASTHARDWARE V2] System hardware optimization complete.\n")
71
+
72
+
73
+ def get_core():
74
+ """
75
+ fasthardware가 최적화 설정을 완료한 OpenVINO Core 싱글톤을 반환합니다.
76
+ speedup() 호출 후 사용하세요.
77
+ """
78
+ global _ov_core
79
+ if _ov_core is None:
80
+ raise RuntimeError("speedup()을 먼저 호출하세요.")
81
+ return _ov_core
82
+
83
+
84
+ def _elevate_priority(process):
85
+ try:
86
+ if sys.platform == "win32":
87
+ process.nice(psutil.HIGH_PRIORITY_CLASS)
88
+ else:
89
+ process.nice(-20)
90
+ except Exception:
91
+ pass
92
+
93
+
94
+ def _optimize_runtime():
95
+ try:
96
+ gc.disable()
97
+ gc.set_threshold(700, 10, 10)
98
+ except Exception:
99
+ pass
100
+
101
+
102
+ def _bind_c_libraries():
103
+ try:
104
+ total_cores = str(os.cpu_count() or 4)
105
+ for flag in ["OMP_NUM_THREADS", "MKL_NUM_THREADS", "OPENBLAS_NUM_THREADS", "NUMEXPR_NUM_THREADS"]:
106
+ os.environ[flag] = total_cores
107
+ except Exception:
108
+ pass
109
+
110
+
111
+ def _accelerate_inference():
112
+ global _ov_core
113
+
114
+ # 1. NVIDIA CUDA (PyTorch)
115
+ try:
116
+ import torch
117
+ if torch.cuda.is_available():
118
+ torch.backends.cudnn.benchmark = True
119
+ torch.backends.cudnn.enabled = True
120
+ torch.backends.cuda.matmul.allow_tf32 = True
121
+ torch.backends.cudnn.allow_tf32 = True
122
+ device_name = torch.cuda.get_device_name(0)
123
+ print(f" -> [CUDA] {device_name} detected. cuDNN benchmark + TF32 engaged.")
124
+ else:
125
+ torch.set_num_threads(os.cpu_count() or 4)
126
+ torch.set_num_interop_threads(os.cpu_count() or 4)
127
+ print(f" -> [PyTorch] CPU mode. Threads maximized to {os.cpu_count()}.")
128
+ except ImportError:
129
+ pass
130
+
131
+ # 2. Intel OpenVINO — 싱글톤 core 생성 및 최적화
132
+ try:
133
+ import openvino as ov
134
+
135
+ core = ov.Core()
136
+
137
+ # 모델 캐시 — 두 번째 실행부터 컴파일 시간 제거
138
+ cache_dir = os.path.join(os.path.expanduser("~"), ".fasthardware_ov_cache")
139
+ os.makedirs(cache_dir, exist_ok=True)
140
+ core.set_property({"CACHE_DIR": cache_dir})
141
+
142
+ if "GPU" in core.available_devices:
143
+ core.set_property("GPU", {"PERFORMANCE_HINT": "LATENCY"})
144
+ print(f" -> [OpenVINO] Intel iGPU detected. LATENCY hint + model cache engaged.")
145
+ else:
146
+ core.set_property("CPU", {"PERFORMANCE_HINT": "THROUGHPUT"})
147
+ print(f" -> [OpenVINO] CPU mode. THROUGHPUT hint engaged.")
148
+
149
+ os.environ["OV_FRONTEND_CACHE_ENABLE"] = "1"
150
+
151
+ # 싱글톤으로 저장 → get_core()로 꺼내 쓸 수 있음
152
+ _ov_core = core
153
+
154
+ except ImportError:
155
+ pass
156
+
157
+ # 3. OpenCV
158
+ try:
159
+ cv2.setUseOptimized(True)
160
+ cv2.setNumThreads(os.cpu_count() or 4)
161
+ if cv2.ocl.haveOpenCL():
162
+ cv2.ocl.setUseOpenCL(True)
163
+ print(f" -> [OpenCV] SIMD + OpenCL acceleration engaged.")
164
+ else:
165
+ print(f" -> [OpenCV] SIMD acceleration engaged.")
166
+ except ImportError:
167
+ pass
168
+
169
+
170
+ def _supercharge_children():
171
+ try:
172
+ children = _current_process.children(recursive=True)
173
+ if not children:
174
+ print(" -> [MP] No child processes detected yet. Buffers ready.")
175
+ return
176
+
177
+ print(f" -> [MP] Detecting {len(children)} child processes. Intercepting...")
178
+
179
+ all_cores = list(range(os.cpu_count() or 4))
180
+ if not all_cores:
181
+ return
182
+
183
+ for i, child in enumerate(children):
184
+ try:
185
+ if child.is_running():
186
+ _elevate_priority(child)
187
+ assigned_core = [all_cores[i % len(all_cores)]]
188
+ child.cpu_affinity(assigned_core)
189
+ print(f" └─ Child [{child.pid}] Supercharged & Bound to Core {assigned_core}")
190
+ except Exception:
191
+ pass
192
+ except Exception:
193
+ pass
194
+
195
+
196
+ def manual_sweep():
197
+ gc.enable()
198
+ gc.collect()
199
+ gc.disable()
200
+
201
+ try:
202
+ if platform.system() == "Windows":
203
+ handle = ctypes.windll.kernel32.OpenProcess(0x1F0FFF, False, os.getpid())
204
+ if handle:
205
+ ctypes.windll.kernel32.SetProcessWorkingSetSize(handle, -1, -1)
206
+ ctypes.windll.kernel32.CloseHandle(handle)
207
+ elif platform.system() == "Linux":
208
+ libc = ctypes.CDLL("libc.so.6")
209
+ libc.malloc_trim(0)
210
+ except Exception:
211
+ pass
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: fasthardware
3
+ Version: 2.2.2
4
+ Summary: Hyper-Performance Environment Setup for AI & Hardware Accelerating
5
+ Author: ungyo
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: numpy>=1.20.0
10
+ Requires-Dist: aiohttp>=3.8.0
11
+ Requires-Dist: requests>=2.25.0
12
+ Requires-Dist: openvino>=2023.0.0
13
+ Requires-Dist: opencv-python>=4.5.0
14
+ Dynamic: author
15
+ Dynamic: classifier
16
+ Dynamic: requires-dist
17
+ Dynamic: requires-python
18
+ Dynamic: summary
@@ -2,8 +2,7 @@ README.md
2
2
  setup.py
3
3
  autopublish/__init__.py
4
4
  autopublish/publisher.py
5
- easy-path/__init__.py
6
- easy-path/easy-path1.py
5
+ cy_yologic/__init__.py
7
6
  fasthardware/__init__.py
8
7
  fasthardware/fasthardware.py
9
8
  fasthardware.egg-info/PKG-INFO
@@ -12,4 +11,6 @@ fasthardware.egg-info/dependency_links.txt
12
11
  fasthardware.egg-info/requires.txt
13
12
  fasthardware.egg-info/top_level.txt
14
13
  package_guardian/__init__.py
15
- package_guardian/guardian1.py
14
+ package_guardian/guardian1.py
15
+ ungyoseries/__init__.py
16
+ ungyoseries/hython.py
@@ -0,0 +1,5 @@
1
+ numpy>=1.20.0
2
+ aiohttp>=3.8.0
3
+ requests>=2.25.0
4
+ openvino>=2023.0.0
5
+ opencv-python>=4.5.0
@@ -1,4 +1,5 @@
1
1
  autopublish
2
- easy-path
2
+ cy_yologic
3
3
  fasthardware
4
4
  package_guardian
5
+ ungyoseries
@@ -0,0 +1,25 @@
1
+ # setup.py
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="fasthardware",
6
+ version="2.2.2",
7
+ description="Hyper-Performance Environment Setup for AI & Hardware Accelerating",
8
+ author="ungyo",
9
+ # 💡 ungyoseries 폴더와 그 하위 패키지(fasthardware)를 통째로 자동 탐색하여 묶습니다.
10
+ packages=find_packages(),
11
+ include_package_data=True,
12
+ python_requires=">=3.8",
13
+ # 💡 보스의 프레임워크가 요구하는 핵심 의존성 라이브러리 자동 매핑
14
+ install_requires=[
15
+ "numpy>=1.20.0",
16
+ "aiohttp>=3.8.0",
17
+ "requests>=2.25.0",
18
+ "openvino>=2023.0.0",
19
+ "opencv-python>=4.5.0",
20
+ ],
21
+ classifiers=[
22
+ "Programming Language :: Python :: 3",
23
+ "Operating System :: Microsoft :: Windows",
24
+ ],
25
+ )
@@ -0,0 +1,9 @@
1
+ from .hython import fasthardware, init, boost, np, aiohttp, requests
2
+ __all__=[
3
+ 'fasthardware',
4
+ 'init',
5
+ 'boost',
6
+ 'np',
7
+ 'aiohttp',
8
+ 'requests'
9
+ ]
@@ -0,0 +1,41 @@
1
+ from fasthardware import fasthardware
2
+ import numpy as np
3
+ import aiohttp
4
+ import requests
5
+ from functools import wraps
6
+
7
+ __all__ = ['fasthardware','np', 'aiohttp', 'requests', 'init', 'boost']
8
+
9
+ _initialized = False
10
+
11
+
12
+ def init(mode="DEFAULT"):
13
+ """
14
+ 프로그램 시작 시 딱 한 번 호출.
15
+ 전체 하드웨어 가속 환경을 초기화합니다.
16
+ mode: "DEFAULT" 또는 "ULTIMATE"
17
+ """
18
+ global _initialized
19
+ print("\n🚀 [HYTHON] Initializing Hyper-Performance Environment...")
20
+ fasthardware.speedup(mode=mode)
21
+ _initialized = True
22
+
23
+
24
+ def boost():
25
+ """
26
+ 함수에 붙이는 데코레이터.
27
+ 함수 실행 후 메모리를 자동으로 정리합니다.
28
+ init()은 별도로 한 번만 호출하세요.
29
+ """
30
+ def decorator(func):
31
+ @wraps(func)
32
+ def wrapper(*args, **kwargs):
33
+ if not _initialized:
34
+ print("[HYTHON] Warning: call init() first.")
35
+ try:
36
+ result = func(*args, **kwargs)
37
+ return result
38
+ finally:
39
+ fasthardware.manual_sweep()
40
+ return wrapper
41
+ return decorator
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fasthardware
3
- Version: 2.0.3
4
- Summary: Maximize the absolute computing power of your Python process with a single line of code.
5
- Author: Choi Woongyo
6
- Author-email: chldnsry1214@gmail.com
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: Microsoft :: Windows
10
- Classifier: Operating System :: POSIX :: Linux
11
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
- Classifier: Topic :: System :: Hardware
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
- Requires-Dist: psutil>=5.9.0
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: requires-dist
22
- Dynamic: requires-python
23
- Dynamic: summary
24
-
25
- Markdown
26
- <p align="center">
27
- <img src="logo.png" alt="fasthardware Official Logo" width="400">
28
- </p>
29
- # ⚡ fasthardware
30
-
31
- [![PyPI version](https://img.shields.io/pypi/v/fasthardware.svg)](https://pypi.org/project/fasthardware/)
32
- [![Downloads](https://pepy.tech/badge/fasthardware)](https://pepy.tech/project/fasthardware)
33
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
-
35
- **Maximize the absolute computing power of your Python process and all its child processes with just a single line of code.**
36
-
37
- `fasthardware` is a lightweight, zero-configuration hardware acceleration injector designed for high-performance, real-time Python applications (e.g., YOLO object detection, MediaPipe pose estimation, OpenCV video pipelines, and heavy distributed inference loops).
38
-
39
- By hijacking the OS scheduler, managing runtime memory thresholds, and forcing strict CPU core binding across multi-processes, `fasthardware` eliminates micro-stuttering and stabilizes frames under heavy loads.
40
-
41
- ---
42
-
43
- ## 🚀 Key Features
44
-
45
- * **OS Priority Escalation:** Automatically forces the host OS (Windows/Linux) to allocate maximum CPU scheduling priority to your Python process.
46
- * **🔥 ULTIMATE Multi-Process Interception:** Automatically tracks all spawned child processes, forces them into high-priority classes, and binds them to dedicated CPU cores (`CPU Affinity`) to eliminate distributed bottlenecks.
47
- * **Micro-Stuttering Elimination:** Optimizes Python's Garbage Collection (GC) thresholds to prevent "Stop-the-World" latency spikes during heavy loops.
48
- * **C-Level Multicore Mobilization:** Injects global environment flags (`OMP`, `MKL`, `OPENBLAS`, `NUMEXPR`) to force underlying C/C++ backed libraries (NumPy, OpenCV) to utilize every single logical core available.
49
- * **Zero-Config Integration:** No code rewrites. Just import it at the very top of your script.
50
-
51
- ---
52
-
53
- ## 📦 Installation
54
-
55
- Install the package directly from PyPI:
56
-
57
- ```bash
58
- pip install fasthardware
59
- ```
60
- 🛠️ Quick Start
61
- 1. Default Mode (Single Process Boost)
62
- Perfect for standard loops like standalone YOLO inference or single-camera stream pipelines.
63
-
64
- ```Python
65
- from fasthardware import fasthardware
66
- ```
67
-
68
- # Unlock maximum priority for the current process
69
- ```Python
70
- fasthardware.speedup()
71
- ```
72
-
73
- # Your heavy real-time loop goes here...
74
- 2. ULTIMATE Mode (Multi-Process & Distributed Boost)
75
- Designed for massive pipelines that spawn child processes (e.g., multi-GPU frameworks, distributed learning, parallel workers). It intercepts all child processes and binds them to specific cores.
76
-
77
- ```Python
78
- from fasthardware import fasthardware
79
- ```
80
-
81
- # Supercharge both main and all child processes recursively
82
- ```Python
83
- fasthardware.speedup(mode="ULTIMATE")
84
- ```
85
-
86
- # Your heavy multiprocessing/distributed pipeline here...
87
- 🧹 Manual Memory Sweeping (Optional)
88
- For ultra-heavy asynchronous pipelines (e.g., blending AI inference with async API requests or audio generation), manually sweep the 0-generation memory cache without breaking your frame rate:
89
-
90
- ```Python
91
- # Call this at the end of your loop iteration if necessary
92
- fasthardware.manual_sweep()
93
- ```
94
- 📊 Performance Impact
95
- Actual benchmarking on heavy real-time pipelines (YOLOv8 Inference + Parallel Workers):
96
-
97
- Standard Python Implementation: ~30 FPS (with frequent micro-stutters and core thrashing)
98
-
99
- With fasthardware (ULTIMATE Mode): 53+ FPS (Stable, zero core competition, 40%+ performance jump)
100
-
101
- 📜 License
102
- This project is licensed under the MIT License - see the LICENSE file for details.
103
-
104
- Developed with ⚡ by Choi Woongyo.
@@ -1,80 +0,0 @@
1
- Markdown
2
- <p align="center">
3
- <img src="logo.png" alt="fasthardware Official Logo" width="400">
4
- </p>
5
- # ⚡ fasthardware
6
-
7
- [![PyPI version](https://img.shields.io/pypi/v/fasthardware.svg)](https://pypi.org/project/fasthardware/)
8
- [![Downloads](https://pepy.tech/badge/fasthardware)](https://pepy.tech/project/fasthardware)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
-
11
- **Maximize the absolute computing power of your Python process and all its child processes with just a single line of code.**
12
-
13
- `fasthardware` is a lightweight, zero-configuration hardware acceleration injector designed for high-performance, real-time Python applications (e.g., YOLO object detection, MediaPipe pose estimation, OpenCV video pipelines, and heavy distributed inference loops).
14
-
15
- By hijacking the OS scheduler, managing runtime memory thresholds, and forcing strict CPU core binding across multi-processes, `fasthardware` eliminates micro-stuttering and stabilizes frames under heavy loads.
16
-
17
- ---
18
-
19
- ## 🚀 Key Features
20
-
21
- * **OS Priority Escalation:** Automatically forces the host OS (Windows/Linux) to allocate maximum CPU scheduling priority to your Python process.
22
- * **🔥 ULTIMATE Multi-Process Interception:** Automatically tracks all spawned child processes, forces them into high-priority classes, and binds them to dedicated CPU cores (`CPU Affinity`) to eliminate distributed bottlenecks.
23
- * **Micro-Stuttering Elimination:** Optimizes Python's Garbage Collection (GC) thresholds to prevent "Stop-the-World" latency spikes during heavy loops.
24
- * **C-Level Multicore Mobilization:** Injects global environment flags (`OMP`, `MKL`, `OPENBLAS`, `NUMEXPR`) to force underlying C/C++ backed libraries (NumPy, OpenCV) to utilize every single logical core available.
25
- * **Zero-Config Integration:** No code rewrites. Just import it at the very top of your script.
26
-
27
- ---
28
-
29
- ## 📦 Installation
30
-
31
- Install the package directly from PyPI:
32
-
33
- ```bash
34
- pip install fasthardware
35
- ```
36
- 🛠️ Quick Start
37
- 1. Default Mode (Single Process Boost)
38
- Perfect for standard loops like standalone YOLO inference or single-camera stream pipelines.
39
-
40
- ```Python
41
- from fasthardware import fasthardware
42
- ```
43
-
44
- # Unlock maximum priority for the current process
45
- ```Python
46
- fasthardware.speedup()
47
- ```
48
-
49
- # Your heavy real-time loop goes here...
50
- 2. ULTIMATE Mode (Multi-Process & Distributed Boost)
51
- Designed for massive pipelines that spawn child processes (e.g., multi-GPU frameworks, distributed learning, parallel workers). It intercepts all child processes and binds them to specific cores.
52
-
53
- ```Python
54
- from fasthardware import fasthardware
55
- ```
56
-
57
- # Supercharge both main and all child processes recursively
58
- ```Python
59
- fasthardware.speedup(mode="ULTIMATE")
60
- ```
61
-
62
- # Your heavy multiprocessing/distributed pipeline here...
63
- 🧹 Manual Memory Sweeping (Optional)
64
- For ultra-heavy asynchronous pipelines (e.g., blending AI inference with async API requests or audio generation), manually sweep the 0-generation memory cache without breaking your frame rate:
65
-
66
- ```Python
67
- # Call this at the end of your loop iteration if necessary
68
- fasthardware.manual_sweep()
69
- ```
70
- 📊 Performance Impact
71
- Actual benchmarking on heavy real-time pipelines (YOLOv8 Inference + Parallel Workers):
72
-
73
- Standard Python Implementation: ~30 FPS (with frequent micro-stutters and core thrashing)
74
-
75
- With fasthardware (ULTIMATE Mode): 53+ FPS (Stable, zero core competition, 40%+ performance jump)
76
-
77
- 📜 License
78
- This project is licensed under the MIT License - see the LICENSE file for details.
79
-
80
- Developed with ⚡ by Choi Woongyo.
@@ -1,68 +0,0 @@
1
- import os
2
- import shutil
3
- import sys
4
-
5
- class Path(str):
6
- """
7
- Super-intuitive Path manipulation library for humans.
8
- Inherits from 'str' so it can be used directly anywhere a string is required.
9
- """
10
-
11
- @classmethod
12
- def here(cls):
13
- """Returns the absolute directory path of the currently executing script."""
14
- # Get the caller's file path frame dynamically
15
- try:
16
- import inspect
17
- frame = inspect.stack()[1]
18
- module = inspect.getmodule(frame[0])
19
- if module and hasattr(module, '__file__'):
20
- return cls(os.path.dirname(os.path.abspath(module.__file__)))
21
- except Exception:
22
- pass
23
- return cls(os.getcwd())
24
-
25
- def __truediv__(self, next_path):
26
- """Enables intuitive slash '/' routing syntax (e.g., Path.here() / 'folder' / 'file.txt')"""
27
- return Path(os.path.join(self, str(next_path)))
28
-
29
- @property
30
- def exists(self):
31
- """Returns True if the path exists on the system."""
32
- return os.path.exists(self)
33
-
34
- @property
35
- def is_file(self):
36
- """Returns True if the path points to a file."""
37
- return os.path.isfile(self)
38
-
39
- @property
40
- def is_dir(self):
41
- """Returns True if the path points to a directory."""
42
- return os.path.isdir(self)
43
-
44
- def change_ext(self, new_ext):
45
- """Changes or adds a file extension easily."""
46
- base, _ = os.path.splitext(self)
47
- if not new_ext.startswith('.'):
48
- new_ext = '.' + new_ext
49
- return Path(base + new_ext)
50
-
51
- def make_dir(self):
52
- """Creates the directory if it does not exist. (Like mkdir -p)"""
53
- os.makedirs(self, exist_ok=True)
54
- return self
55
-
56
- def read(self, encoding="utf-8"):
57
- """Reads file content in a single line."""
58
- with open(self, "r", encoding=encoding) as f:
59
- return f.read()
60
-
61
- def write(self, content, encoding="utf-8"):
62
- """Writes content to the file in a single line. Automatically creates parent directories if missing."""
63
- parent = os.path.dirname(self)
64
- if parent:
65
- os.makedirs(parent, exist_ok=True)
66
- with open(self, "w", encoding=encoding) as f:
67
- f.write(str(content))
68
- return self
@@ -1,2 +0,0 @@
1
- # 옆에 있는 fasthardware.py 모듈을 패키지 루트로 끌어올립니다.
2
- from . import fasthardware
@@ -1,78 +0,0 @@
1
- import os
2
- import sys
3
- import psutil
4
- import gc
5
-
6
- _current_process = psutil.Process(os.getpid())
7
-
8
-
9
- def speedup(mode="DEFAULT"):
10
- print(f"\n [FASTHARDWARE V2] Tuning mode: {mode}...")
11
-
12
- _elevate_priority(_current_process)
13
- _optimize_runtime()
14
- _bind_c_libraries()
15
-
16
- if mode == "ULTIMATE":
17
- _supercharge_children()
18
-
19
- print(" [FASTHARDWARE V2] System hardware optimization complete.\n")
20
-
21
-
22
- def _elevate_priority(process):
23
- try:
24
- if sys.platform == "win32":
25
- process.nice(psutil.HIGH_PRIORITY_CLASS)
26
- else:
27
- process.nice(-20)
28
- except Exception:
29
- pass
30
-
31
-
32
- def _optimize_runtime():
33
- try:
34
- gc.disable()
35
- gc.set_threshold(700, 10, 10)
36
- except Exception:
37
- pass
38
-
39
-
40
- def _bind_c_libraries():
41
- try:
42
- total_cores = str(os.cpu_count() or 4)
43
- for flag in ["OMP_NUM_THREADS", "MKL_NUM_THREADS", "OPENBLAS_NUM_THREADS", "NUMEXPR_NUM_THREADS"]:
44
- os.environ[flag] = total_cores
45
- except Exception:
46
- pass
47
-
48
-
49
- def _supercharge_children():
50
- try:
51
- children = _current_process.children(recursive=True)
52
- if not children:
53
- print(" -> [MP] No child processes detected yet. Buffers ready.")
54
- return
55
-
56
- print(f" -> [MP] Detecting {len(children)} child processes. Intercepting...")
57
-
58
- all_cores = list(range(os.cpu_count() or 4))
59
- if not all_cores:
60
- return
61
-
62
- for i, child in enumerate(children):
63
- try:
64
- if child.is_running():
65
- _elevate_priority(child)
66
- assigned_core = [all_cores[i % len(all_cores)]]
67
- child.cpu_affinity(assigned_core)
68
- print(f" └─ Child [{child.pid}] Supercharged & Bound to Core {assigned_core}")
69
- except Exception:
70
- pass
71
- except Exception:
72
- pass
73
-
74
-
75
- def manual_sweep():
76
- gc.enable()
77
- gc.collect(0)
78
- gc.disable()
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fasthardware
3
- Version: 2.0.3
4
- Summary: Maximize the absolute computing power of your Python process with a single line of code.
5
- Author: Choi Woongyo
6
- Author-email: chldnsry1214@gmail.com
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: Microsoft :: Windows
10
- Classifier: Operating System :: POSIX :: Linux
11
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
- Classifier: Topic :: System :: Hardware
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
- Requires-Dist: psutil>=5.9.0
16
- Dynamic: author
17
- Dynamic: author-email
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: description-content-type
21
- Dynamic: requires-dist
22
- Dynamic: requires-python
23
- Dynamic: summary
24
-
25
- Markdown
26
- <p align="center">
27
- <img src="logo.png" alt="fasthardware Official Logo" width="400">
28
- </p>
29
- # ⚡ fasthardware
30
-
31
- [![PyPI version](https://img.shields.io/pypi/v/fasthardware.svg)](https://pypi.org/project/fasthardware/)
32
- [![Downloads](https://pepy.tech/badge/fasthardware)](https://pepy.tech/project/fasthardware)
33
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
-
35
- **Maximize the absolute computing power of your Python process and all its child processes with just a single line of code.**
36
-
37
- `fasthardware` is a lightweight, zero-configuration hardware acceleration injector designed for high-performance, real-time Python applications (e.g., YOLO object detection, MediaPipe pose estimation, OpenCV video pipelines, and heavy distributed inference loops).
38
-
39
- By hijacking the OS scheduler, managing runtime memory thresholds, and forcing strict CPU core binding across multi-processes, `fasthardware` eliminates micro-stuttering and stabilizes frames under heavy loads.
40
-
41
- ---
42
-
43
- ## 🚀 Key Features
44
-
45
- * **OS Priority Escalation:** Automatically forces the host OS (Windows/Linux) to allocate maximum CPU scheduling priority to your Python process.
46
- * **🔥 ULTIMATE Multi-Process Interception:** Automatically tracks all spawned child processes, forces them into high-priority classes, and binds them to dedicated CPU cores (`CPU Affinity`) to eliminate distributed bottlenecks.
47
- * **Micro-Stuttering Elimination:** Optimizes Python's Garbage Collection (GC) thresholds to prevent "Stop-the-World" latency spikes during heavy loops.
48
- * **C-Level Multicore Mobilization:** Injects global environment flags (`OMP`, `MKL`, `OPENBLAS`, `NUMEXPR`) to force underlying C/C++ backed libraries (NumPy, OpenCV) to utilize every single logical core available.
49
- * **Zero-Config Integration:** No code rewrites. Just import it at the very top of your script.
50
-
51
- ---
52
-
53
- ## 📦 Installation
54
-
55
- Install the package directly from PyPI:
56
-
57
- ```bash
58
- pip install fasthardware
59
- ```
60
- 🛠️ Quick Start
61
- 1. Default Mode (Single Process Boost)
62
- Perfect for standard loops like standalone YOLO inference or single-camera stream pipelines.
63
-
64
- ```Python
65
- from fasthardware import fasthardware
66
- ```
67
-
68
- # Unlock maximum priority for the current process
69
- ```Python
70
- fasthardware.speedup()
71
- ```
72
-
73
- # Your heavy real-time loop goes here...
74
- 2. ULTIMATE Mode (Multi-Process & Distributed Boost)
75
- Designed for massive pipelines that spawn child processes (e.g., multi-GPU frameworks, distributed learning, parallel workers). It intercepts all child processes and binds them to specific cores.
76
-
77
- ```Python
78
- from fasthardware import fasthardware
79
- ```
80
-
81
- # Supercharge both main and all child processes recursively
82
- ```Python
83
- fasthardware.speedup(mode="ULTIMATE")
84
- ```
85
-
86
- # Your heavy multiprocessing/distributed pipeline here...
87
- 🧹 Manual Memory Sweeping (Optional)
88
- For ultra-heavy asynchronous pipelines (e.g., blending AI inference with async API requests or audio generation), manually sweep the 0-generation memory cache without breaking your frame rate:
89
-
90
- ```Python
91
- # Call this at the end of your loop iteration if necessary
92
- fasthardware.manual_sweep()
93
- ```
94
- 📊 Performance Impact
95
- Actual benchmarking on heavy real-time pipelines (YOLOv8 Inference + Parallel Workers):
96
-
97
- Standard Python Implementation: ~30 FPS (with frequent micro-stutters and core thrashing)
98
-
99
- With fasthardware (ULTIMATE Mode): 53+ FPS (Stable, zero core competition, 40%+ performance jump)
100
-
101
- 📜 License
102
- This project is licensed under the MIT License - see the LICENSE file for details.
103
-
104
- Developed with ⚡ by Choi Woongyo.
@@ -1 +0,0 @@
1
- psutil>=5.9.0
File without changes
@@ -1,38 +0,0 @@
1
- import os
2
- from setuptools import setup, find_packages
3
-
4
- # README.md 파싱 및 인코딩 방어막 구축
5
- long_description = ""
6
- if os.path.exists("README.md"):
7
- with open("README.md", "r", encoding="utf-8") as fh:
8
- long_description = fh.read()
9
-
10
- setup(
11
- name="fasthardware",
12
- version="2.0.3", # 🌟 새 README 반영 기념 빌드업 버전!
13
- author="Choi Woongyo",
14
- author_email="chldnsry1214@gmail.com", # 보스의 이메일로 변경 가능합니다.
15
- description="Maximize the absolute computing power of your Python process with a single line of code.",
16
- long_description=long_description,
17
- long_description_content_type="text/markdown",
18
-
19
- # 패키지 폴더 내부 구조 자동 추적
20
- packages=find_packages(),
21
- include_package_data=True,
22
-
23
- # 하드웨어 제어 핵심 엔진 의존성 피드
24
- install_requires=[
25
- "psutil>=5.9.0",
26
- ],
27
-
28
- # PyPI 글로벌 카테고리 태그 세팅
29
- classifiers=[
30
- "Programming Language :: Python :: 3",
31
- "License :: OSI Approved :: MIT License",
32
- "Operating System :: Microsoft :: Windows",
33
- "Operating System :: POSIX :: Linux",
34
- "Topic :: Software Development :: Libraries :: Python Modules",
35
- "Topic :: System :: Hardware",
36
- ],
37
- python_requires=">=3.8",
38
- )
File without changes