This repository hosts the optimized versions of the Gemma-3 vision models to accelerate inference with ONNX Runtime.
Optimized models are published here in ONNX format to run with ONNX Runtime on CPU and GPU across devices, including server platforms, Windows, Linux and Mac desktops, and mobile CPUs, with the precision best suited to each of these targets.
You can see how to run the examples with ORT GenAI
here.
1# Download the model directly using the Hugging Face CLI
2# Replace `model_name` with one of the following options: `gemma-3-4b-it`, `gemma-3-12b-it`, or `gemma-3-27b-it`
3huggingface-cli download onnxruntime/Gemma-3-ONNX --include {model_name}/cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .
4
5# Install the CPU package of ONNX Runtime GenAI
6pip install --pre onnxruntime-genai
7
8# Please adjust the model directory (-m) accordingly
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
10curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-mm.py -o model-mm.py
11python model-mm.py -m {model_name}/cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e cpu
1# Download the model directly using the Hugging Face CLI
2# Replace `model_name` with one of the following options: `gemma-3-4b-it`, `gemma-3-12b-it`, or `gemma-3-27b-it`
3huggingface-cli download onnxruntime/Gemma-3-ONNX --include {model_name}/gpu/cuda-bf16-io-int4-rtn-block-32/* --local-dir .
4
5# Install the CUDA package of ONNX Runtime GenAI
6pip install --pre onnxruntime-genai-cuda
7
8# Please adjust the model directory (-m) accordingly
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
10curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-mm.py -o model-mm.py
11python model-mm.py -m {model_name}/gpu/cuda-bf16-io-int4-rtn-block-32/ -e cuda
1# Download the model directly using the Hugging Face CLI
2# Replace `model_name` with one of the following options: `gemma-3-4b-it`, `gemma-3-12b-it`, or `gemma-3-27b-it`
3huggingface-cli download onnxruntime/Gemma-3-ONNX --include {model_name}/gpu/gpu-fp16-io-int4-rtn-block-32/* --local-dir .
4
5# Install the DML package of ONNX Runtime GenAI
6pip install --pre onnxruntime-genai-directml
7
8# Please adjust the model directory (-m) accordingly
9curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/common.py -o common.py
10curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-mm.py -o model-mm.py
11python model-mm.py -m {model_name}/gpu/gpu-fp16-io-int4-rtn-block-32/ -e dml