fasthardware 2.1.0__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.2.2/cy_yologic/__init__.py +2 -0
  4. fasthardware-2.2.2/fasthardware/__init__.py +14 -0
  5. {fasthardware-2.1.0 → fasthardware-2.2.2}/fasthardware/fasthardware.py +47 -7
  6. fasthardware-2.2.2/fasthardware.egg-info/PKG-INFO +18 -0
  7. {fasthardware-2.1.0 → fasthardware-2.2.2}/fasthardware.egg-info/SOURCES.txt +4 -5
  8. fasthardware-2.2.2/fasthardware.egg-info/requires.txt +5 -0
  9. {fasthardware-2.1.0 → fasthardware-2.2.2}/fasthardware.egg-info/top_level.txt +2 -2
  10. fasthardware-2.2.2/setup.py +25 -0
  11. fasthardware-2.2.2/ungyoseries/__init__.py +9 -0
  12. {fasthardware-2.1.0/hython → fasthardware-2.2.2/ungyoseries}/hython.py +2 -2
  13. fasthardware-2.1.0/PKG-INFO +0 -173
  14. fasthardware-2.1.0/README.md +0 -150
  15. fasthardware-2.1.0/easy-path/easy-path1.py +0 -68
  16. fasthardware-2.1.0/fasthardware/__init__.py +0 -2
  17. fasthardware-2.1.0/fasthardware.egg-info/PKG-INFO +0 -173
  18. fasthardware-2.1.0/fasthardware.egg-info/requires.txt +0 -1
  19. fasthardware-2.1.0/hython/__init__.py +0 -1
  20. fasthardware-2.1.0/package_guardian/__init__.py +0 -0
  21. fasthardware-2.1.0/setup.py +0 -26
  22. {fasthardware-2.1.0 → fasthardware-2.2.2}/autopublish/__init__.py +0 -0
  23. {fasthardware-2.1.0 → fasthardware-2.2.2}/autopublish/publisher.py +0 -0
  24. {fasthardware-2.1.0 → fasthardware-2.2.2}/fasthardware.egg-info/dependency_links.txt +0 -0
  25. {fasthardware-2.1.0/easy-path → fasthardware-2.2.2/package_guardian}/__init__.py +0 -0
  26. {fasthardware-2.1.0 → fasthardware-2.2.2}/package_guardian/guardian1.py +0 -0
  27. {fasthardware-2.1.0 → 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()
@@ -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
+ ]
@@ -4,11 +4,58 @@ import psutil
4
4
  import gc
5
5
  import ctypes
6
6
  import platform
7
+ import cv2
8
+ import threading
9
+ import numpy as np
7
10
 
8
11
  _current_process = psutil.Process(os.getpid())
9
12
  _ov_core = None # 싱글톤 OpenVINO core
10
13
 
11
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
+ # ─────────────────────────────────────────
12
59
  def speedup(mode="DEFAULT"):
13
60
  print(f"\n [FASTHARDWARE V2] Tuning mode: {mode}...")
14
61
 
@@ -64,9 +111,7 @@ def _bind_c_libraries():
64
111
  def _accelerate_inference():
65
112
  global _ov_core
66
113
 
67
- # ─────────────────────────────────────────
68
114
  # 1. NVIDIA CUDA (PyTorch)
69
- # ─────────────────────────────────────────
70
115
  try:
71
116
  import torch
72
117
  if torch.cuda.is_available():
@@ -83,9 +128,7 @@ def _accelerate_inference():
83
128
  except ImportError:
84
129
  pass
85
130
 
86
- # ─────────────────────────────────────────
87
131
  # 2. Intel OpenVINO — 싱글톤 core 생성 및 최적화
88
- # ─────────────────────────────────────────
89
132
  try:
90
133
  import openvino as ov
91
134
 
@@ -111,11 +154,8 @@ def _accelerate_inference():
111
154
  except ImportError:
112
155
  pass
113
156
 
114
- # ─────────────────────────────────────────
115
157
  # 3. OpenCV
116
- # ─────────────────────────────────────────
117
158
  try:
118
- import cv2
119
159
  cv2.setUseOptimized(True)
120
160
  cv2.setNumThreads(os.cpu_count() or 4)
121
161
  if cv2.ocl.haveOpenCL():
@@ -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
@@ -11,7 +10,7 @@ fasthardware.egg-info/SOURCES.txt
11
10
  fasthardware.egg-info/dependency_links.txt
12
11
  fasthardware.egg-info/requires.txt
13
12
  fasthardware.egg-info/top_level.txt
14
- hython/__init__.py
15
- hython/hython.py
16
13
  package_guardian/__init__.py
17
- 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,5 +1,5 @@
1
1
  autopublish
2
- easy-path
2
+ cy_yologic
3
3
  fasthardware
4
- hython
5
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
+ ]
@@ -4,7 +4,7 @@ import aiohttp
4
4
  import requests
5
5
  from functools import wraps
6
6
 
7
- __all__ = ['np', 'aiohttp', 'requests', 'init', 'boost']
7
+ __all__ = ['fasthardware','np', 'aiohttp', 'requests', 'init', 'boost']
8
8
 
9
9
  _initialized = False
10
10
 
@@ -38,4 +38,4 @@ def boost():
38
38
  finally:
39
39
  fasthardware.manual_sweep()
40
40
  return wrapper
41
- return decorator
41
+ return decorator
@@ -1,173 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fasthardware
3
- Version: 2.1.0
4
- Summary: A zero-configuration hardware acceleration library for Python.
5
- Home-page: https://github.com/yourusername/fasthardware
6
- Author: 최운교
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Classifier: Topic :: System :: Hardware
11
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
- Requires-Python: >=3.8
13
- Description-Content-Type: text/markdown
14
- Requires-Dist: psutil
15
- Dynamic: author
16
- Dynamic: classifier
17
- Dynamic: description
18
- Dynamic: description-content-type
19
- Dynamic: home-page
20
- Dynamic: requires-dist
21
- Dynamic: requires-python
22
- Dynamic: summary
23
-
24
- # ⚡ fasthardware
25
-
26
- **A zero-configuration hardware acceleration library for Python.**
27
- Squeeze every last FPS out of your system with a single function call — covering OS scheduling, CPU threading, GPU inference, and memory management.
28
-
29
- ---
30
-
31
- ## 🚀 Installation
32
-
33
- ```bash
34
- pip install fasthardware
35
- ```
36
-
37
- ---
38
-
39
- ## 🔥 Quick Start
40
-
41
- ```python
42
- from fasthardware import fasthardware
43
-
44
- # Call once at startup — automatically detects and optimizes your hardware
45
- fasthardware.speedup()
46
-
47
- # Your code here
48
- ...
49
-
50
- # Periodically sweep RAM fragmentation (recommended every 60s)
51
- fasthardware.manual_sweep()
52
- ```
53
-
54
- ---
55
-
56
- ## 🧠 What does it do?
57
-
58
- `fasthardware` automatically detects your hardware and applies the most effective low-level optimizations — no manual configuration needed.
59
-
60
- ### `speedup(mode="DEFAULT")`
61
-
62
- | Layer | Optimization | Description |
63
- |---|---|---|
64
- | **OS** | Process Priority Elevation | Calls kernel APIs directly to set process to HIGH priority |
65
- | **CPU** | C Library Thread Binding | Sets `OMP / MKL / OPENBLAS / NUMEXPR` threads to max cores |
66
- | **GC** | Stutter Prevention | Disables Python GC to eliminate random frame drops |
67
- | **CUDA** | cuDNN Benchmark + TF32 | Auto-selects optimal kernels; enables TF32 on Ampere+ GPUs |
68
- | **OpenVINO** | iGPU LATENCY hint + Model Cache | Minimizes inference latency; caches compiled models to disk |
69
- | **OpenCV** | SIMD + OpenCL | Forces AVX/SSE acceleration and OpenCL parallel backend |
70
-
71
- > Only installed libraries are optimized — missing ones are silently skipped.
72
-
73
- #### ULTIMATE mode
74
- ```python
75
- fasthardware.speedup(mode="ULTIMATE")
76
- ```
77
- Additionally detects all child processes (multiprocessing workers) and:
78
- - Elevates their OS priority
79
- - Pins each worker to a dedicated CPU core for zero cache contention
80
-
81
- ---
82
-
83
- ### `get_core()` — OpenVINO Core Singleton
84
-
85
- After calling `speedup()`, fasthardware holds an optimized OpenVINO `Core` instance internally.
86
- Instead of creating your own `ov.Core()`, reuse this to inherit all applied optimizations:
87
-
88
- ```python
89
- from fasthardware import fasthardware
90
- import openvino as ov
91
-
92
- fasthardware.speedup()
93
-
94
- # ✅ Reuse the pre-optimized Core — LATENCY hint + model cache already applied
95
- core = fasthardware.get_core()
96
-
97
- compiled_model = core.compile_model("model.xml", "GPU")
98
- ```
99
-
100
- > If you create `ov.Core()` manually after `speedup()`, the `PERFORMANCE_HINT` set by fasthardware will not carry over. Use `get_core()` to avoid this.
101
-
102
- ---
103
-
104
- ### `manual_sweep()`
105
-
106
- Goes beyond Python's `gc.collect()` — performs a full 3-generation GC sweep and calls OS-level memory APIs to return fragmented RAM back to the system.
107
-
108
- | Platform | Method |
109
- |---|---|
110
- | **Windows** | `SetProcessWorkingSetSize(-1, -1)` via `kernel32` |
111
- | **Linux** | `malloc_trim(0)` via `libc` |
112
-
113
- Recommended: call every 60 seconds in long-running inference loops.
114
-
115
- ---
116
-
117
- ## 🎯 Designed For
118
-
119
- - Real-time computer vision pipelines (YOLOv8, OpenVINO, OpenCV)
120
- - High-FPS webcam inference loops
121
- - Edge AI on Intel iGPU / N-series / Core Ultra
122
- - Multiprocessing workloads needing tight CPU affinity control
123
- - Any Python app where consistent, stutter-free performance matters
124
-
125
- ---
126
-
127
- ## 📊 Real-World Results
128
-
129
- Tested on **Intel N100 (integrated GPU)** running YOLOv8n-pose with OpenVINO:
130
-
131
- | Metric | Without fasthardware | With fasthardware |
132
- |---|---|---|
133
- | Peak FPS | baseline | +5 ~ 15 FPS |
134
- | Frame stutters | frequent | eliminated |
135
- | Memory creep (long runs) | gradual degradation | suppressed |
136
-
137
- ---
138
-
139
- ## ⚙️ Full API Reference
140
-
141
- ```python
142
- # Initialize — call once at startup
143
- fasthardware.speedup(mode="DEFAULT") # Standard optimization
144
- fasthardware.speedup(mode="ULTIMATE") # + child process supercharging
145
-
146
- # Get the pre-optimized OpenVINO Core singleton
147
- core = fasthardware.get_core() # Call after speedup()
148
-
149
- # Sweep memory — call periodically
150
- fasthardware.manual_sweep()
151
- ```
152
-
153
- ---
154
-
155
- ## 🛡️ Safety
156
-
157
- - Priority set to **HIGH** (not REALTIME) — system stability preserved
158
- - GC disabled during runtime; call `gc.enable()` on exit if needed
159
- - All kernel API calls wrapped in try/except — fails silently without permissions
160
- - Tested on Windows 11 and Ubuntu 22.04
161
-
162
- ---
163
-
164
- ## 📄 License
165
-
166
- MIT License
167
-
168
- ---
169
-
170
- ## 🤝 Contributing
171
-
172
- Issues and PRs are welcome.
173
- If fasthardware helped your project hit a new FPS record, feel free to share it!
@@ -1,150 +0,0 @@
1
- # ⚡ fasthardware
2
-
3
- **A zero-configuration hardware acceleration library for Python.**
4
- Squeeze every last FPS out of your system with a single function call — covering OS scheduling, CPU threading, GPU inference, and memory management.
5
-
6
- ---
7
-
8
- ## 🚀 Installation
9
-
10
- ```bash
11
- pip install fasthardware
12
- ```
13
-
14
- ---
15
-
16
- ## 🔥 Quick Start
17
-
18
- ```python
19
- from fasthardware import fasthardware
20
-
21
- # Call once at startup — automatically detects and optimizes your hardware
22
- fasthardware.speedup()
23
-
24
- # Your code here
25
- ...
26
-
27
- # Periodically sweep RAM fragmentation (recommended every 60s)
28
- fasthardware.manual_sweep()
29
- ```
30
-
31
- ---
32
-
33
- ## 🧠 What does it do?
34
-
35
- `fasthardware` automatically detects your hardware and applies the most effective low-level optimizations — no manual configuration needed.
36
-
37
- ### `speedup(mode="DEFAULT")`
38
-
39
- | Layer | Optimization | Description |
40
- |---|---|---|
41
- | **OS** | Process Priority Elevation | Calls kernel APIs directly to set process to HIGH priority |
42
- | **CPU** | C Library Thread Binding | Sets `OMP / MKL / OPENBLAS / NUMEXPR` threads to max cores |
43
- | **GC** | Stutter Prevention | Disables Python GC to eliminate random frame drops |
44
- | **CUDA** | cuDNN Benchmark + TF32 | Auto-selects optimal kernels; enables TF32 on Ampere+ GPUs |
45
- | **OpenVINO** | iGPU LATENCY hint + Model Cache | Minimizes inference latency; caches compiled models to disk |
46
- | **OpenCV** | SIMD + OpenCL | Forces AVX/SSE acceleration and OpenCL parallel backend |
47
-
48
- > Only installed libraries are optimized — missing ones are silently skipped.
49
-
50
- #### ULTIMATE mode
51
- ```python
52
- fasthardware.speedup(mode="ULTIMATE")
53
- ```
54
- Additionally detects all child processes (multiprocessing workers) and:
55
- - Elevates their OS priority
56
- - Pins each worker to a dedicated CPU core for zero cache contention
57
-
58
- ---
59
-
60
- ### `get_core()` — OpenVINO Core Singleton
61
-
62
- After calling `speedup()`, fasthardware holds an optimized OpenVINO `Core` instance internally.
63
- Instead of creating your own `ov.Core()`, reuse this to inherit all applied optimizations:
64
-
65
- ```python
66
- from fasthardware import fasthardware
67
- import openvino as ov
68
-
69
- fasthardware.speedup()
70
-
71
- # ✅ Reuse the pre-optimized Core — LATENCY hint + model cache already applied
72
- core = fasthardware.get_core()
73
-
74
- compiled_model = core.compile_model("model.xml", "GPU")
75
- ```
76
-
77
- > If you create `ov.Core()` manually after `speedup()`, the `PERFORMANCE_HINT` set by fasthardware will not carry over. Use `get_core()` to avoid this.
78
-
79
- ---
80
-
81
- ### `manual_sweep()`
82
-
83
- Goes beyond Python's `gc.collect()` — performs a full 3-generation GC sweep and calls OS-level memory APIs to return fragmented RAM back to the system.
84
-
85
- | Platform | Method |
86
- |---|---|
87
- | **Windows** | `SetProcessWorkingSetSize(-1, -1)` via `kernel32` |
88
- | **Linux** | `malloc_trim(0)` via `libc` |
89
-
90
- Recommended: call every 60 seconds in long-running inference loops.
91
-
92
- ---
93
-
94
- ## 🎯 Designed For
95
-
96
- - Real-time computer vision pipelines (YOLOv8, OpenVINO, OpenCV)
97
- - High-FPS webcam inference loops
98
- - Edge AI on Intel iGPU / N-series / Core Ultra
99
- - Multiprocessing workloads needing tight CPU affinity control
100
- - Any Python app where consistent, stutter-free performance matters
101
-
102
- ---
103
-
104
- ## 📊 Real-World Results
105
-
106
- Tested on **Intel N100 (integrated GPU)** running YOLOv8n-pose with OpenVINO:
107
-
108
- | Metric | Without fasthardware | With fasthardware |
109
- |---|---|---|
110
- | Peak FPS | baseline | +5 ~ 15 FPS |
111
- | Frame stutters | frequent | eliminated |
112
- | Memory creep (long runs) | gradual degradation | suppressed |
113
-
114
- ---
115
-
116
- ## ⚙️ Full API Reference
117
-
118
- ```python
119
- # Initialize — call once at startup
120
- fasthardware.speedup(mode="DEFAULT") # Standard optimization
121
- fasthardware.speedup(mode="ULTIMATE") # + child process supercharging
122
-
123
- # Get the pre-optimized OpenVINO Core singleton
124
- core = fasthardware.get_core() # Call after speedup()
125
-
126
- # Sweep memory — call periodically
127
- fasthardware.manual_sweep()
128
- ```
129
-
130
- ---
131
-
132
- ## 🛡️ Safety
133
-
134
- - Priority set to **HIGH** (not REALTIME) — system stability preserved
135
- - GC disabled during runtime; call `gc.enable()` on exit if needed
136
- - All kernel API calls wrapped in try/except — fails silently without permissions
137
- - Tested on Windows 11 and Ubuntu 22.04
138
-
139
- ---
140
-
141
- ## 📄 License
142
-
143
- MIT License
144
-
145
- ---
146
-
147
- ## 🤝 Contributing
148
-
149
- Issues and PRs are welcome.
150
- If fasthardware helped your project hit a new FPS record, feel free to share it!
@@ -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,173 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fasthardware
3
- Version: 2.1.0
4
- Summary: A zero-configuration hardware acceleration library for Python.
5
- Home-page: https://github.com/yourusername/fasthardware
6
- Author: 최운교
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Classifier: Topic :: System :: Hardware
11
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
- Requires-Python: >=3.8
13
- Description-Content-Type: text/markdown
14
- Requires-Dist: psutil
15
- Dynamic: author
16
- Dynamic: classifier
17
- Dynamic: description
18
- Dynamic: description-content-type
19
- Dynamic: home-page
20
- Dynamic: requires-dist
21
- Dynamic: requires-python
22
- Dynamic: summary
23
-
24
- # ⚡ fasthardware
25
-
26
- **A zero-configuration hardware acceleration library for Python.**
27
- Squeeze every last FPS out of your system with a single function call — covering OS scheduling, CPU threading, GPU inference, and memory management.
28
-
29
- ---
30
-
31
- ## 🚀 Installation
32
-
33
- ```bash
34
- pip install fasthardware
35
- ```
36
-
37
- ---
38
-
39
- ## 🔥 Quick Start
40
-
41
- ```python
42
- from fasthardware import fasthardware
43
-
44
- # Call once at startup — automatically detects and optimizes your hardware
45
- fasthardware.speedup()
46
-
47
- # Your code here
48
- ...
49
-
50
- # Periodically sweep RAM fragmentation (recommended every 60s)
51
- fasthardware.manual_sweep()
52
- ```
53
-
54
- ---
55
-
56
- ## 🧠 What does it do?
57
-
58
- `fasthardware` automatically detects your hardware and applies the most effective low-level optimizations — no manual configuration needed.
59
-
60
- ### `speedup(mode="DEFAULT")`
61
-
62
- | Layer | Optimization | Description |
63
- |---|---|---|
64
- | **OS** | Process Priority Elevation | Calls kernel APIs directly to set process to HIGH priority |
65
- | **CPU** | C Library Thread Binding | Sets `OMP / MKL / OPENBLAS / NUMEXPR` threads to max cores |
66
- | **GC** | Stutter Prevention | Disables Python GC to eliminate random frame drops |
67
- | **CUDA** | cuDNN Benchmark + TF32 | Auto-selects optimal kernels; enables TF32 on Ampere+ GPUs |
68
- | **OpenVINO** | iGPU LATENCY hint + Model Cache | Minimizes inference latency; caches compiled models to disk |
69
- | **OpenCV** | SIMD + OpenCL | Forces AVX/SSE acceleration and OpenCL parallel backend |
70
-
71
- > Only installed libraries are optimized — missing ones are silently skipped.
72
-
73
- #### ULTIMATE mode
74
- ```python
75
- fasthardware.speedup(mode="ULTIMATE")
76
- ```
77
- Additionally detects all child processes (multiprocessing workers) and:
78
- - Elevates their OS priority
79
- - Pins each worker to a dedicated CPU core for zero cache contention
80
-
81
- ---
82
-
83
- ### `get_core()` — OpenVINO Core Singleton
84
-
85
- After calling `speedup()`, fasthardware holds an optimized OpenVINO `Core` instance internally.
86
- Instead of creating your own `ov.Core()`, reuse this to inherit all applied optimizations:
87
-
88
- ```python
89
- from fasthardware import fasthardware
90
- import openvino as ov
91
-
92
- fasthardware.speedup()
93
-
94
- # ✅ Reuse the pre-optimized Core — LATENCY hint + model cache already applied
95
- core = fasthardware.get_core()
96
-
97
- compiled_model = core.compile_model("model.xml", "GPU")
98
- ```
99
-
100
- > If you create `ov.Core()` manually after `speedup()`, the `PERFORMANCE_HINT` set by fasthardware will not carry over. Use `get_core()` to avoid this.
101
-
102
- ---
103
-
104
- ### `manual_sweep()`
105
-
106
- Goes beyond Python's `gc.collect()` — performs a full 3-generation GC sweep and calls OS-level memory APIs to return fragmented RAM back to the system.
107
-
108
- | Platform | Method |
109
- |---|---|
110
- | **Windows** | `SetProcessWorkingSetSize(-1, -1)` via `kernel32` |
111
- | **Linux** | `malloc_trim(0)` via `libc` |
112
-
113
- Recommended: call every 60 seconds in long-running inference loops.
114
-
115
- ---
116
-
117
- ## 🎯 Designed For
118
-
119
- - Real-time computer vision pipelines (YOLOv8, OpenVINO, OpenCV)
120
- - High-FPS webcam inference loops
121
- - Edge AI on Intel iGPU / N-series / Core Ultra
122
- - Multiprocessing workloads needing tight CPU affinity control
123
- - Any Python app where consistent, stutter-free performance matters
124
-
125
- ---
126
-
127
- ## 📊 Real-World Results
128
-
129
- Tested on **Intel N100 (integrated GPU)** running YOLOv8n-pose with OpenVINO:
130
-
131
- | Metric | Without fasthardware | With fasthardware |
132
- |---|---|---|
133
- | Peak FPS | baseline | +5 ~ 15 FPS |
134
- | Frame stutters | frequent | eliminated |
135
- | Memory creep (long runs) | gradual degradation | suppressed |
136
-
137
- ---
138
-
139
- ## ⚙️ Full API Reference
140
-
141
- ```python
142
- # Initialize — call once at startup
143
- fasthardware.speedup(mode="DEFAULT") # Standard optimization
144
- fasthardware.speedup(mode="ULTIMATE") # + child process supercharging
145
-
146
- # Get the pre-optimized OpenVINO Core singleton
147
- core = fasthardware.get_core() # Call after speedup()
148
-
149
- # Sweep memory — call periodically
150
- fasthardware.manual_sweep()
151
- ```
152
-
153
- ---
154
-
155
- ## 🛡️ Safety
156
-
157
- - Priority set to **HIGH** (not REALTIME) — system stability preserved
158
- - GC disabled during runtime; call `gc.enable()` on exit if needed
159
- - All kernel API calls wrapped in try/except — fails silently without permissions
160
- - Tested on Windows 11 and Ubuntu 22.04
161
-
162
- ---
163
-
164
- ## 📄 License
165
-
166
- MIT License
167
-
168
- ---
169
-
170
- ## 🤝 Contributing
171
-
172
- Issues and PRs are welcome.
173
- If fasthardware helped your project hit a new FPS record, feel free to share it!
@@ -1 +0,0 @@
1
- psutil
@@ -1 +0,0 @@
1
- from .hython import init, boost, np, aiohttp, requests
File without changes
@@ -1,26 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- with open("README.md", "r", encoding="utf-8") as f:
4
- long_description = f.read()
5
-
6
- setup(
7
- name="fasthardware",
8
- version="2.1.0",
9
- author="최운교",
10
- description="A zero-configuration hardware acceleration library for Python.",
11
- long_description=long_description,
12
- long_description_content_type="text/markdown",
13
- url="https://github.com/yourusername/fasthardware",
14
- packages=find_packages(),
15
- install_requires=[
16
- "psutil",
17
- ],
18
- classifiers=[
19
- "Programming Language :: Python :: 3",
20
- "License :: OSI Approved :: MIT License",
21
- "Operating System :: OS Independent",
22
- "Topic :: System :: Hardware",
23
- "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
- ],
25
- python_requires=">=3.8",
26
- )
File without changes