End-to-end benchmark pipeline: nn-dataset → PyTorch export (via direct module import) → ONNX → Unity Barracuda (Desktop Headless Batchmode) → JSON logs.
The Unity benchmark project is embedded directly inside the main repository:
nn-vr/
├── data/
├── db/
├── logs/
├── NNVRBenchmark/
│ ├── Assets/
│ ├── Packages/
│ └── ProjectSettings/
├── main.py
├── vr_runner.py
└── README.md
The Unity project is used as the runtime execution layer for Barracuda inference benchmarking.
When embedding Unity inside a Git repository, Unity generates thousands of temporary/cache files. Most of these should NOT be committed.
These folders should remain under version control:
Assets/
Packages/
ProjectSettings/
These contain source code, scenes, scripts, package dependencies, and reproducible project configuration.
These are generated automatically and can always be rebuilt locally:
Library/
Temp/
Obj/
Build/
Builds/
Logs/
MemoryCaptures/
UserSettings/
.vscode/
.idea/
*.csproj
*.sln
If Library/, Temp/, or generated project files are deleted, simply reopen the project in Unity and they will be regenerated automatically.
- Python 3.10+
- Unity 2022.3+ (for desktop batchmode inference)
- Barracuda package installed inside Unity
# Create virtual environment
python -m venv .venv
# Activate on Linux/macOS
source .venv/bin/activate
# Activate on Windows (PowerShell)
# If blocked by execution policy, run first: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
.venv\Scripts\Activate.ps1Install dependencies:
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu126
# pip install onnx onnxscript onnxruntimeInstall nn-dataset (GitHub source required):
pip install --no-cache-dir --upgrade --force git+https://github.com/ABrain-One/nn-dataset --extra-index-url https://download.pytorch.org/whl/cu126Verify:
python -c "import ab.nn.nn; print('OK')"Unity 2022.3.62f3 (changeset 96770f904ca7) must be installed via Unity Hub.
Use the provided install scripts to automate this — they install Unity Hub if absent, then pull the exact editor version:
Windows (PowerShell — run from repo root):
# If blocked by execution policy, run first:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
.\scripts\install-unity.ps1Linux (Ubuntu / Debian):
bash install-unity.shmacOS (Intel + Apple Silicon):
bash scripts/install-unity-macos.shAll three scripts skip installation if the correct Unity version is already present. The macOS script tries Homebrew first, falls back to direct DMG download.
After installation, open NNVRBenchmark/ in Unity Hub and ensure the target platform is set to your local desktop OS (Windows/PC, Mac, or Linux Standalone) so that ComputePrecompiled shaders are built for the local GPU.
Required Unity packages (installed via Package Manager inside Unity):
- Barracuda
- Burst
- Mathematics
The main.py orchestrator supports running the entire pipeline for all models, a single model, or a selective list of models.
To process every model available in the dataset (Export + Unity Benchmark):
python main.pyPass the model name as a positional argument:
python main.py AirNetPass a comma-separated list of model names:
python main.py ResNet,UNet2D,GoogLeNetIf you only want to run Stage 1 (ONNX Export) and skip the Unity benchmarking:
python main.py AirNet --skip-deviceIf you only want to run Stage 2 (Unity Benchmark) on already exported ONNX files:
python main.py AirNet --benchmark-onlyIf you are processing many models and want to save disk space, use the --low-storage flag. This will interleave ONNX exporting and Unity benchmarking, automatically deleting each .onnx file immediately after it's benchmarked:
python main.py --low-storageThe export pipeline is resumable. If an ONNX model already exists in _work/onnx_temp/, export is skipped automatically.
You can force a re-export of all models by adding the --force flag.
To automatically clone the nn-dataset repository, push your local generated telemetry from out/ to GitHub, and clean up the local disk space when the pipeline finishes, append the --push-dataset flag:
python main.py --push-datasetResults are appended to results.jsonl (JSON Lines format).
Note: Benchmark outputs (results.jsonl, unity_benchmarks.json) are intentionally gitignored to prevent committing volatile runtime data.
Each entry contains:
- model metadata
- runtime/backend info
- CPU/GPU/NPU timing
- tensor dimensions
- Unity version
- device analytics
- crash/failure information
Models are processed locally and results are routed directly into the dataset output directories.
| Status | Meaning |
|---|---|
success |
Inference completed successfully |
partial |
Model loaded but timings failed |
runtime_error |
Unity/Barracuda crashed |
unsupported |
Unsupported ONNX/Barracuda operation |
timeout |
Benchmark exceeded timeout |
| Path | Role |
|---|---|
main.py |
Pipeline orchestrator |
process_models.py |
Stage 1: ONNX exporter & evaluator |
benchmark_models.py |
Stage 2: Unity benchmark orchestrator |
model_loader.py |
nn-dataset integration |
onnx_exporter.py |
Dynamic import + ONNX export (opset 14, static shapes) |
vr_runner.py |
(Legacy) ADB push/pull + Unity launcher |
unity_runner.py |
Unity desktop batchmode benchmark runner interface |
logger.py |
JSON logging |
NNVRBenchmark/ |
Unity benchmark runtime (Barracuda inference) |
nn-dataset row
↓
PyTorch model
↓
ONNX export (opset 12, IR 7)
↓
Unity Barracuda inference (Desktop Headless Batchmode)
↓
JSON benchmark output
↓
out/nn/stat/run/onnx/fp32/ (per-model JSON artifacts)
