A zero-configuration hardware acceleration library for Python.
Project description
⚡ fasthardware
A zero-configuration hardware acceleration library for Python.
Squeeze every last FPS out of your system with a single function call — covering OS scheduling, CPU threading, GPU inference, and memory management.
🚀 Installation
pip install fasthardware
🔥 Quick Start
from fasthardware import fasthardware
# Call once at startup — automatically detects and optimizes your hardware
fasthardware.speedup()
# Your code here
...
# Periodically sweep RAM fragmentation (recommended every 60s)
fasthardware.manual_sweep()
🧠 What does it do?
fasthardware automatically detects your hardware and applies the most effective low-level optimizations — no manual configuration needed.
speedup(mode="DEFAULT")
| Layer | Optimization | Description |
|---|---|---|
| OS | Process Priority Elevation | Calls kernel APIs directly to set process to HIGH priority |
| CPU | C Library Thread Binding | Sets OMP / MKL / OPENBLAS / NUMEXPR threads to max cores |
| GC | Stutter Prevention | Disables Python GC to eliminate random frame drops |
| CUDA | cuDNN Benchmark + TF32 | Auto-selects optimal kernels; enables TF32 on Ampere+ GPUs |
| OpenVINO | iGPU LATENCY hint + Model Cache | Minimizes inference latency; caches compiled models to disk |
| OpenCV | SIMD + OpenCL | Forces AVX/SSE acceleration and OpenCL parallel backend |
Only installed libraries are optimized — missing ones are silently skipped.
ULTIMATE mode
fasthardware.speedup(mode="ULTIMATE")
Additionally detects all child processes (multiprocessing workers) and:
- Elevates their OS priority
- Pins each worker to a dedicated CPU core for zero cache contention
get_core() — OpenVINO Core Singleton
After calling speedup(), fasthardware holds an optimized OpenVINO Core instance internally.
Instead of creating your own ov.Core(), reuse this to inherit all applied optimizations:
from fasthardware import fasthardware
import openvino as ov
fasthardware.speedup()
# ✅ Reuse the pre-optimized Core — LATENCY hint + model cache already applied
core = fasthardware.get_core()
compiled_model = core.compile_model("model.xml", "GPU")
If you create
ov.Core()manually afterspeedup(), thePERFORMANCE_HINTset by fasthardware will not carry over. Useget_core()to avoid this.
manual_sweep()
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.
| Platform | Method |
|---|---|
| Windows | SetProcessWorkingSetSize(-1, -1) via kernel32 |
| Linux | malloc_trim(0) via libc |
Recommended: call every 60 seconds in long-running inference loops.
🎯 Designed For
- Real-time computer vision pipelines (YOLOv8, OpenVINO, OpenCV)
- High-FPS webcam inference loops
- Edge AI on Intel iGPU / N-series / Core Ultra
- Multiprocessing workloads needing tight CPU affinity control
- Any Python app where consistent, stutter-free performance matters
📊 Real-World Results
Tested on Intel N100 (integrated GPU) running YOLOv8n-pose with OpenVINO:
| Metric | Without fasthardware | With fasthardware |
|---|---|---|
| Peak FPS | baseline | +5 ~ 15 FPS |
| Frame stutters | frequent | eliminated |
| Memory creep (long runs) | gradual degradation | suppressed |
⚙️ Full API Reference
# Initialize — call once at startup
fasthardware.speedup(mode="DEFAULT") # Standard optimization
fasthardware.speedup(mode="ULTIMATE") # + child process supercharging
# Get the pre-optimized OpenVINO Core singleton
core = fasthardware.get_core() # Call after speedup()
# Sweep memory — call periodically
fasthardware.manual_sweep()
🛡️ Safety
- Priority set to HIGH (not REALTIME) — system stability preserved
- GC disabled during runtime; call
gc.enable()on exit if needed - All kernel API calls wrapped in try/except — fails silently without permissions
- Tested on Windows 11 and Ubuntu 22.04
📄 License
MIT License
🤝 Contributing
Issues and PRs are welcome.
If fasthardware helped your project hit a new FPS record, feel free to share it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fasthardware-2.1.0.tar.gz.
File metadata
- Download URL: fasthardware-2.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b43d4036855d5b8d5f8bc3d29920e4b6eb5a89a668aad634b5186f5a271344e
|
|
| MD5 |
b5aa61d02cecd64bf57095f0350f40e3
|
|
| BLAKE2b-256 |
3ae7646bd3540d7cee521bf99675c047d6e8a3cfa5a15e2393172fab2ad165a6
|
File details
Details for the file fasthardware-2.1.0-py3-none-any.whl.
File metadata
- Download URL: fasthardware-2.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
599c8db4b685fcb54f58632a576399aba8c8f1838f632d8e5293fdeec087e19f
|
|
| MD5 |
2ad5627fdcd7ce1b3ad49345b47cade3
|
|
| BLAKE2b-256 |
77988b9f6c738feb8dd863893a6259b54931322becce97423d73ca60bcf306d0
|