|
| 1 | +# ============================================================================== |
| 2 | +# ExecuTorch Targets Makefile |
| 3 | +# ============================================================================== |
| 4 | +# |
| 5 | +# This Makefile provides convenient targets for building ExecuTorch model runners |
| 6 | +# with different backend configurations (CPU, CUDA, Metal), as well as other |
| 7 | +# binary targets. |
| 8 | +# |
| 9 | +# WHAT THIS BUILDS: |
| 10 | +# ----------------- |
| 11 | +# Each target builds: |
| 12 | +# 1. ExecuTorch core libraries with the specified backend (CPU, CUDA, or Metal) |
| 13 | +# 2. The model-specific runner executable in cmake-out/examples/models/<model>/ |
| 14 | +# |
| 15 | +# SUPPORTED MODELS: |
| 16 | +# ----------------- |
| 17 | +# - voxtral: Multimodal voice + text model (CPU, CUDA, Metal) |
| 18 | +# - whisper: Speech recognition model (CPU, CUDA, Metal) |
| 19 | +# - llama: Text generation model (CPU) |
| 20 | +# - llava: Vision + language model (CPU) |
| 21 | +# - gemma3: Text generation model (CPU, CUDA) |
| 22 | +# |
| 23 | +# USAGE: |
| 24 | +# ------ |
| 25 | +# make <model>-<backend> # Build a specific model with a backend |
| 26 | +# make help # Show all available targets |
| 27 | +# make clean # Remove all build artifacts |
| 28 | +# |
| 29 | +# Examples: |
| 30 | +# make voxtral-cuda # Build Voxtral with CUDA backend |
| 31 | +# make llama-cpu # Build Llama with CPU backend |
| 32 | +# make whisper-metal # Build Whisper with Metal backend (macOS) |
| 33 | +# |
| 34 | +# HOW TO ADD A NEW MODEL: |
| 35 | +# ----------------------- |
| 36 | +# To add a new model (e.g., "mymodel"), follow these steps: |
| 37 | +# |
| 38 | +# 1. Create a CMakePresets.json in examples/models/mymodel/: |
| 39 | +# - Define configurePresets for each backend (base, cpu, cuda, metal) |
| 40 | +# - Define buildPresets with the target name from CMakeLists.txt |
| 41 | +# - Define workflowPresets that combine configure + build steps |
| 42 | +# - See examples/models/voxtral/CMakePresets.json for multi-backend reference |
| 43 | +# - Or see examples/models/llama/CMakePresets.json for simple single-preset reference |
| 44 | +# |
| 45 | +# 2. Add targets to this Makefile: |
| 46 | +# a) Add to .PHONY declaration: mymodel-cuda mymodel-cpu mymodel-metal |
| 47 | +# b) Add help text in the help target |
| 48 | +# c) Add target implementations following this pattern: |
| 49 | +# |
| 50 | +# mymodel-cuda: |
| 51 | +# @echo "==> Building and installing ExecuTorch with CUDA..." |
| 52 | +# cmake --workflow --preset llm-release-cuda |
| 53 | +# @echo "==> Building MyModel runner with CUDA..." |
| 54 | +# cd examples/models/mymodel && cmake --workflow --preset mymodel-cuda |
| 55 | +# @echo "" |
| 56 | +# @echo "✓ Build complete!" |
| 57 | +# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner" |
| 58 | +# |
| 59 | +# mymodel-cpu: |
| 60 | +# @echo "==> Building and installing ExecuTorch..." |
| 61 | +# cmake --workflow --preset llm-release |
| 62 | +# @echo "==> Building MyModel runner (CPU)..." |
| 63 | +# cd examples/models/mymodel && cmake --workflow --preset mymodel-cpu |
| 64 | +# @echo "" |
| 65 | +# @echo "✓ Build complete!" |
| 66 | +# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner" |
| 67 | +# |
| 68 | +# mymodel-metal: |
| 69 | +# @echo "==> Building and installing ExecuTorch with Metal..." |
| 70 | +# cmake --workflow --preset llm-release-metal |
| 71 | +# @echo "==> Building MyModel runner with Metal..." |
| 72 | +# cd examples/models/mymodel && cmake --workflow --preset mymodel-metal |
| 73 | +# @echo "" |
| 74 | +# @echo "✓ Build complete!" |
| 75 | +# @echo " Binary: cmake-out/examples/models/mymodel/mymodel_runner" |
| 76 | +# |
| 77 | +# 3. Test your new targets: |
| 78 | +# make mymodel-cpu # or mymodel-cuda, mymodel-metal |
| 79 | +# |
| 80 | +# NOTES: |
| 81 | +# ------ |
| 82 | +# - CUDA backend is only available on Linux systems |
| 83 | +# - Metal backend is only available on macOS (Darwin) systems |
| 84 | +# - Some models may not support all backends (check model documentation) |
| 85 | +# - Binary outputs are located in cmake-out/examples/models/<model>/ |
| 86 | +# - The preset names in CMakePresets.json must match the names used in Makefile |
| 87 | +# |
| 88 | +# ============================================================================== |
| 89 | + |
| 90 | +.PHONY: voxtral-cuda voxtral-cpu voxtral-metal whisper-cuda whisper-cpu whisper-metal llama-cpu llava-cpu gemma3-cuda gemma3-cpu clean help |
| 91 | + |
| 92 | +help: |
| 93 | + @echo "This Makefile adds targets to build runners for various models on various backends. Run using `make <target>`. Available targets:" |
| 94 | + @echo " voxtral-cuda - Build Voxtral runner with CUDA backend" |
| 95 | + @echo " voxtral-cpu - Build Voxtral runner with CPU backend" |
| 96 | + @echo " voxtral-metal - Build Voxtral runner with Metal backend (macOS only)" |
| 97 | + @echo " whisper-cuda - Build Whisper runner with CUDA backend" |
| 98 | + @echo " whisper-cpu - Build Whisper runner with CPU backend" |
| 99 | + @echo " whisper-metal - Build Whisper runner with Metal backend (macOS only)" |
| 100 | + @echo " llama-cpu - Build Llama runner with CPU backend" |
| 101 | + @echo " llava-cpu - Build Llava runner with CPU backend" |
| 102 | + @echo " gemma3-cuda - Build Gemma3 runner with CUDA backend" |
| 103 | + @echo " gemma3-cpu - Build Gemma3 runner with CPU backend" |
| 104 | + @echo " clean - Clean build artifacts" |
| 105 | + |
| 106 | +voxtral-cuda: |
| 107 | + @echo "==> Building and installing ExecuTorch with CUDA..." |
| 108 | + cmake --workflow --preset llm-release-cuda |
| 109 | + @echo "==> Building Voxtral runner with CUDA..." |
| 110 | + cd examples/models/voxtral && cmake --workflow --preset voxtral-cuda |
| 111 | + @echo "" |
| 112 | + @echo "✓ Build complete!" |
| 113 | + @echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner" |
| 114 | + |
| 115 | +voxtral-cpu: |
| 116 | + @echo "==> Building and installing ExecuTorch..." |
| 117 | + cmake --workflow --preset llm-release |
| 118 | + @echo "==> Building Voxtral runner (CPU)..." |
| 119 | + cd examples/models/voxtral && cmake --workflow --preset voxtral-cpu |
| 120 | + @echo "" |
| 121 | + @echo "✓ Build complete!" |
| 122 | + @echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner" |
| 123 | + |
| 124 | +voxtral-metal: |
| 125 | + @echo "==> Building and installing ExecuTorch with Metal..." |
| 126 | + cmake --workflow --preset llm-release-metal |
| 127 | + @echo "==> Building Voxtral runner with Metal..." |
| 128 | + cd examples/models/voxtral && cmake --workflow --preset voxtral-metal |
| 129 | + @echo "" |
| 130 | + @echo "✓ Build complete!" |
| 131 | + @echo " Binary: cmake-out/examples/models/voxtral/voxtral_runner" |
| 132 | + |
| 133 | +whisper-cuda: |
| 134 | + @echo "==> Building and installing ExecuTorch with CUDA..." |
| 135 | + cmake --workflow --preset llm-release-cuda |
| 136 | + @echo "==> Building Whisper runner with CUDA..." |
| 137 | + cd examples/models/whisper && cmake --workflow --preset whisper-cuda |
| 138 | + @echo "" |
| 139 | + @echo "✓ Build complete!" |
| 140 | + @echo " Binary: cmake-out/examples/models/whisper/whisper_runner" |
| 141 | + |
| 142 | +whisper-cpu: |
| 143 | + @echo "==> Building and installing ExecuTorch..." |
| 144 | + cmake --workflow --preset llm-release |
| 145 | + @echo "==> Building Whisper runner (CPU)..." |
| 146 | + cd examples/models/whisper && cmake --workflow --preset whisper-cpu |
| 147 | + @echo "" |
| 148 | + @echo "✓ Build complete!" |
| 149 | + @echo " Binary: cmake-out/examples/models/whisper/whisper_runner" |
| 150 | + |
| 151 | +whisper-metal: |
| 152 | + @echo "==> Building and installing ExecuTorch with Metal..." |
| 153 | + cmake --workflow --preset llm-release-metal |
| 154 | + @echo "==> Building Whisper runner with Metal..." |
| 155 | + cd examples/models/whisper && cmake --workflow --preset whisper-metal |
| 156 | + @echo "" |
| 157 | + @echo "✓ Build complete!" |
| 158 | + @echo " Binary: cmake-out/examples/models/whisper/whisper_runner" |
| 159 | + |
| 160 | +llama-cpu: |
| 161 | + @echo "==> Building and installing ExecuTorch..." |
| 162 | + cmake --workflow --preset llm-release |
| 163 | + @echo "==> Building Llama runner (CPU)..." |
| 164 | + cd examples/models/llama && cmake --workflow --preset llama-release |
| 165 | + @echo "" |
| 166 | + @echo "✓ Build complete!" |
| 167 | + @echo " Binary: cmake-out/examples/models/llama/llama_main" |
| 168 | + |
| 169 | +llava-cpu: |
| 170 | + @echo "==> Building and installing ExecuTorch..." |
| 171 | + cmake --workflow --preset llm-release |
| 172 | + @echo "==> Building Llava runner (CPU)..." |
| 173 | + cd examples/models/llava && cmake --workflow --preset llava |
| 174 | + @echo "" |
| 175 | + @echo "✓ Build complete!" |
| 176 | + @echo " Binary: cmake-out/examples/models/llava/llava_main" |
| 177 | + |
| 178 | +gemma3-cuda: |
| 179 | + @echo "==> Building and installing ExecuTorch with CUDA..." |
| 180 | + cmake --workflow --preset llm-release-cuda |
| 181 | + @echo "==> Building Gemma3 runner with CUDA..." |
| 182 | + cd examples/models/gemma3 && cmake --workflow --preset gemma3-cuda |
| 183 | + @echo "" |
| 184 | + @echo "✓ Build complete!" |
| 185 | + @echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner" |
| 186 | + |
| 187 | +gemma3-cpu: |
| 188 | + @echo "==> Building and installing ExecuTorch..." |
| 189 | + cmake --workflow --preset llm-release |
| 190 | + @echo "==> Building Gemma3 runner (CPU)..." |
| 191 | + cd examples/models/gemma3 && cmake --workflow --preset gemma3-cpu |
| 192 | + @echo "" |
| 193 | + @echo "✓ Build complete!" |
| 194 | + @echo " Binary: cmake-out/examples/models/gemma3/gemma3_e2e_runner" |
| 195 | + |
| 196 | +clean: |
| 197 | + rm -rf cmake-out |
0 commit comments