Status: Validated Version: 1.0.0 Date: 2025-11-16 Issue: #53 - OpenVINO Validation & Production Deployment Author: mrveiss
OpenVINO (Open Visual Inference and Neural Network Optimization) provides CPU and GPU optimization for AI inference workloads in AutoBot. This guide covers setup, validation, and production deployment.
| Component | Status | Location |
|---|---|---|
| OpenVINO Runtime | ✅ Installed | venv/lib/python3.14/site-packages/openvino/ |
| CPU Plugin | ✅ Available | libopenvino_intel_cpu_plugin.so |
| GPU Plugin | ✅ Installed | libopenvino_intel_gpu_plugin.so |
| NPU Plugin | ✅ Installed | libopenvino_intel_npu_plugin.so |
| Setup Script | ✅ Created | scripts/setup/setup_openvino.sh |
| LangChain Integration | ✅ Available | Embeddings and Reranking support |
Available Devices: ['CPU']
CPU: Intel(R) Core(TM) Ultra 9 185H
Note: GPU and NPU plugins installed but not detected in WSL2 environment. Native Linux or Windows deployment will have full accelerator access.
OpenVINO is already installed in the main AutoBot venv:
# Activate main venv
source venv/bin/activate
# Verify installation
python3 -c "from openvino.runtime import Core; print(Core().available_devices)"For isolated testing or development:
# Run setup script
bash scripts/setup/setup_openvino.sh
# Activate OpenVINO environment
source venvs/openvino_env/bin/activatefrom openvino.runtime import Core
core = Core()
devices = core.available_devices
print(f"Available devices: {devices}")
for device in devices:
name = core.get_property(device, "FULL_DEVICE_NAME")
print(f" {device}: {name}")from openvino.runtime import Core, CompiledModel
core = Core()
# Load ONNX model
model = core.read_model("model.onnx")
# Compile for CPU
compiled_cpu = core.compile_model(model, "CPU")
# Compile for GPU (if available)
if "GPU" in core.available_devices:
compiled_gpu = core.compile_model(model, "GPU")
# Auto device selection (best available)
compiled_auto = core.compile_model(model, "AUTO")from openvino.runtime import Core
from openvino.properties import hint
core = Core()
# Latency-optimized inference
config_latency = {hint.performance_mode: hint.PerformanceMode.LATENCY}
compiled = core.compile_model(model, "CPU", config_latency)
# Throughput-optimized inference
config_throughput = {hint.performance_mode: hint.PerformanceMode.THROUGHPUT}
compiled = core.compile_model(model, "CPU", config_throughput)# OpenVINO Embeddings
from langchain_community.embeddings.openvino import OpenVINOEmbeddings
embeddings = OpenVINOEmbeddings(
model_name_or_path="sentence-transformers/all-MiniLM-L6-v2",
model_kwargs={"device": "CPU"},
encode_kwargs={"normalize_embeddings": True}
)
# OpenVINO Reranking
from langchain_community.document_compressors.openvino_rerank import OpenVINOReranker
reranker = OpenVINOReranker(
model_name_or_path="cross-encoder/ms-marco-MiniLM-L-6-v2",
device="CPU"
)Located in: backend/services/knowledge_service.py
Potential optimization: Use OpenVINO-optimized embeddings for faster vector generation.
# Current (standard embeddings)
from langchain_huggingface import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
# OpenVINO-optimized
from langchain_community.embeddings.openvino import OpenVINOEmbeddings
embeddings = OpenVINOEmbeddings(model_name_or_path="all-MiniLM-L6-v2")Located in: autobot-backend/api/knowledge.py
Use OpenVINO for reranking retrieved documents.
Located in: src/voice_processing_system.py
Potential for OpenVINO-optimized speech recognition models.
Compares inference performance:
- Native PyTorch/TensorFlow
- OpenVINO CPU
- OpenVINO GPU (when available)
| Workload | Native | OpenVINO CPU | Improvement |
|---|---|---|---|
| Text Embeddings | 100ms | 60-80ms | 20-40% |
| Document Reranking | 150ms | 90-120ms | 20-40% |
| Image Classification | 200ms | 100-140ms | 30-50% |
Note: Actual performance depends on model architecture, batch size, and hardware.
Add to .env:
# OpenVINO Configuration
OPENVINO_ENABLED=true
OPENVINO_DEVICE=AUTO # AUTO, CPU, GPU, NPU
OPENVINO_NUM_THREADS=4
OPENVINO_CACHE_DIR=/tmp/openvino_cache# Dockerfile additions for OpenVINO
FROM python:3.14-slim
# Install OpenVINO dependencies
RUN apt-get update && apt-get install -y \
libgomp1 \
ocl-icd-libopencl1 \
&& rm -rf /var/lib/apt/lists/*
# Install OpenVINO
RUN pip install openvino openvino-dev[pytorch,onnx]
# Set OpenVINO environment
ENV OPENVINO_CACHE_DIR=/app/openvino_cacheTrack OpenVINO performance via Prometheus metrics:
from prometheus_client import Histogram
openvino_inference_time = Histogram(
"openvino_inference_seconds",
"OpenVINO inference time",
["model", "device"]
)
with openvino_inference_time.labels(model="embeddings", device="CPU").time():
result = compiled_model(input_tensor)Symptoms:
- Only CPU appears in
available_devices - GPU plugin installed but not functional
Solutions:
-
WSL2 Environment:
- GPU passthrough limited in WSL2
- Use native Linux/Windows for GPU acceleration
-
Driver Installation:
# Check Intel GPU driver lspci | grep -i vga # Install Intel compute runtime (native Linux) sudo apt install intel-opencl-icd
-
OpenCL Configuration:
# Verify OpenCL clinfo
Symptoms:
RuntimeError: Cannot compile model- Unsupported operations
Solutions:
-
Convert model to IR format:
mo --input_model model.onnx --output_dir ./ir_model
-
Check supported operations:
from openvino.runtime import Core core = Core() # List supported ops for device
Symptoms:
- OpenVINO slower than native inference
- High CPU usage
Solutions:
-
Enable model caching:
config = {"CACHE_DIR": "/tmp/openvino_cache"} compiled = core.compile_model(model, "CPU", config)
-
Adjust thread count:
from openvino.properties import inference_num_threads config = {inference_num_threads: 4}
-
Use appropriate performance hints:
# Latency for single requests # Throughput for batch processing
Run OpenVINO validation suite:
# All OpenVINO tests
python -m pytest tests/openvino/ -v
# Specific test categories
python -m pytest tests/openvino/ -k "device_detection"
python -m pytest tests/openvino/ -k "model_compilation"
python -m pytest tests/openvino/ -k "benchmark"- Model Caching: Ensure cache directory has appropriate permissions
- Resource Limits: Set thread limits to prevent CPU exhaustion
- Input Validation: Validate model inputs to prevent inference attacks
- Model Integrity: Verify model checksums before loading
- NPU Integration: Full Intel NPU support for Core Ultra processors
- Dynamic Quantization: INT8/INT4 quantization for faster inference
- Model Optimization Tool: Automated model conversion and optimization
- GPU Memory Management: Efficient GPU memory allocation
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2025-11-16 | Initial documentation (Issue #53) |