This repository contains a high-performance multithreaded Fast API server acting as an endpoint for the onnx-community/gemma-4-E2B-it-ONNX multimodal model. It utilizes the powerful underlying native C++ arrays via Open Neural Network Exchange (ONNX) sessions, completely running out-of-core calculations and fully mapping text, image, and audio models across the system GPU properly via the CUDAExecutionProvider.
<|think|> tokens into the user context before chat application parsing via flags.This server is highly configurable. You can launch instances optimized for specific server workloads directly via the command line, shutting down large portions of the machine learning model that are not necessary!
Start the server normally with all inference endpoints accessible and loaded:
uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
Want to build an isolated speech agent while ignoring vision dependencies? For Mac/Linux:
GEMMA_ENABLE_VISION=false uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
For Windows (PowerShell):
$env:GEMMA_ENABLE_VISION="false"; uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
Perfect for lightweight instances. Only embed_tokens and decoder nodes will be initialized onto the CUDA Provider.
For Mac/Linux:
GEMMA_ENABLE_VISION=false GEMMA_ENABLE_AUDIO=false uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
For Windows (PowerShell):
$env:GEMMA_ENABLE_VISION="false"; $env:GEMMA_ENABLE_AUDIO="false"; uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
You can offload specific model components to CPU by creating an engine_config.json file in the project root.
Example (offload text and audio to CPU, keep image on GPU):
{
"audio": "cpu",
"image": "gpu",
"text": "cpu"
}
Each key (text, image, audio) accepts either "cpu" or "gpu".
Missing keys default to "gpu" when running with CUDA.
onnxruntime-gpu, torch, and native CUDA hooks must be properly configured across your UV environment for CUDAExecutionProvider parameters to capture natively.
This repository contains a high-performance multithreaded Fast API server acting as an endpoint for the onnx-community/gemma-4-E2B-it-ONNX multimodal model. It utilizes the powerful underlying native C++ arrays via Open Neural Network Exchange (ONNX) sessions, completely running out-of-core calculations and fully mapping text, image, and audio models across the system GPU properly via the CUDAExecutionProvider.
<|think|> tokens into the user context before chat application parsing via flags.This server is highly configurable. You can launch instances optimized for specific server workloads directly via the command line, shutting down large portions of the machine learning model that are not necessary!
Start the server normally with all inference endpoints accessible and loaded:
uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
Want to build an isolated speech agent while ignoring vision dependencies? For Mac/Linux:
GEMMA_ENABLE_VISION=false uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
For Windows (PowerShell):
$env:GEMMA_ENABLE_VISION="false"; uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
Perfect for lightweight instances. Only embed_tokens and decoder nodes will be initialized onto the CUDA Provider.
For Mac/Linux:
GEMMA_ENABLE_VISION=false GEMMA_ENABLE_AUDIO=false uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
For Windows (PowerShell):
$env:GEMMA_ENABLE_VISION="false"; $env:GEMMA_ENABLE_AUDIO="false"; uv run python -m uvicorn app:app --host 0.0.0.0 --port 8000
You can offload specific model components to CPU by creating an engine_config.json file in the project root.
Example (offload text and audio to CPU, keep image on GPU):
{
"audio": "cpu",
"image": "gpu",
"text": "cpu"
}
Each key (text, image, audio) accepts either "cpu" or "gpu".
Missing keys default to "gpu" when running with CUDA.
onnxruntime-gpu, torch, and native CUDA hooks must be properly configured across your UV environment for CUDAExecutionProvider parameters to capture natively.