Skip to content

Commit 802fec8

Browse files
committed
Add Windows prebuilt packaging docs
1 parent 11d5057 commit 802fec8

5 files changed

Lines changed: 534 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ __pycache__/
2121
/target_proj/
2222
/nocommit/
2323
/perf/
24+
/windows_prebuild/
2425
/*.wav
2526
/flutter/
2627
/.cache/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ make -f Makefile.windows cuda NATIVE_CPU=OFF JOBS=16
184184

185185
The Windows script configures `build/windows-cuda-release` by default and builds `audiocpp_cli`. CUDA presets enable CUDA, CUDA graphs, OpenMP, Ninja, `/utf-8`, `/EHsc`, MSVC OpenMP SIMD support with `/openmp:experimental`, and native CPU optimization by default. The CPU preset uses the same MSVC/Ninja/OpenMP setup without requiring CUDA. CUDA presets auto-detect the local GPU CUDA architecture when `nvidia-smi` is available. Pass `-NativeCpu OFF` or `NATIVE_CPU=OFF` to use portable CPU kernels.
186186

187+
For Windows prebuilt release zips and CPU compatibility profiles, see [docs/windows_build.md](docs/windows_build.md).
188+
187189
Useful variants:
188190

189191
```powershell
@@ -588,6 +590,7 @@ The Python-reference side of these tests usually requires more time-consuming se
588590
## Projects
589591

590592
- [Pocket TTS Browser Engine](https://github.com/jjmlovesgit/pocket-tts-browser-engine) uses audio.cpp to bring fully local PocketTTS voices into Chrome and Edge through the browser TTS API.
593+
- [GuideAnts](https://github.com/Elumenotion/GuideAnts) uses audio.cpp as the default local AI stack path for basic ASR and TTS, with planned reusable skills for audio.cpp scenarios and model configurations.
591594

592595
## Performance Metrics
593596

docs/windows_build.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Windows Build and Prebuilt Packages
2+
3+
This document covers native Windows builds and release zip packaging.
4+
5+
## Requirements for Building
6+
7+
- Visual Studio Build Tools 2022 or newer with the C++ desktop workload
8+
- MSVC x64 compiler, Windows SDK, CMake, Ninja, and MSVC OpenMP components
9+
- Official NVIDIA CUDA Toolkit for CUDA builds
10+
11+
The Visual Studio IDE is not required.
12+
13+
## Native Builds
14+
15+
CPU:
16+
17+
```powershell
18+
.\scripts\build_windows.ps1 -Preset windows-cpu-release -Target audiocpp_cli -Jobs 16
19+
.\scripts\build_windows.ps1 -Preset windows-cpu-release -Target audiocpp_server -Jobs 16
20+
```
21+
22+
CUDA:
23+
24+
```powershell
25+
.\scripts\build_windows.ps1 -Preset windows-cuda-release -Target audiocpp_cli -Jobs 16
26+
.\scripts\build_windows.ps1 -Preset windows-cuda-release -Target audiocpp_server -Jobs 16
27+
```
28+
29+
The CUDA build also includes the CPU backend, so the same binary can run with `--backend cpu` or `--backend cuda`.
30+
31+
## CPU Architecture Profiles
32+
33+
The Windows build script supports explicit CPU architecture selection:
34+
35+
```powershell
36+
.\scripts\build_windows.ps1 -Preset windows-cpu-release -Target audiocpp_cli -CpuArch native
37+
.\scripts\build_windows.ps1 -Preset windows-cpu-release -Target audiocpp_cli -CpuArch avx2
38+
.\scripts\build_windows.ps1 -Preset windows-cpu-release -Target audiocpp_cli -CpuArch baseline
39+
```
40+
41+
| Profile | Build flag | Use when | Performance |
42+
| --- | --- | --- | --- |
43+
| Fast | `-CpuArch native` | You build for your own machine or machines with very similar CPUs. | Fastest, but may use AVX512 or other host-specific instructions. |
44+
| Balance | `-CpuArch avx2` | You want a good default for most modern Windows PCs. | Usually close to native on many systems, more compatible than native. |
45+
| Portable | `-CpuArch baseline` | You want the broadest compatibility. | Slowest, avoids AVX/AVX2/AVX512 selection. |
46+
47+
`-NativeCpu ON/OFF` is still available for compatibility, but release packaging should prefer `-CpuArch`.
48+
49+
## Prebuilt Release Zips
50+
51+
Use the package script to build binaries, copy runtime DLLs, generate a package README, and create zips:
52+
53+
```powershell
54+
.\scripts\package_windows_prebuilt.ps1 -Package all -Profile balance -Jobs 16
55+
```
56+
57+
For CUDA packages, the package script uses a multi-architecture CUDA default derived from the installed CUDA Toolkit instead of the local GPU auto-detect path. This makes release zips more suitable for unknown Windows machines. Pass `-CudaArchitectures auto` only for a local machine-specific package.
58+
59+
Package choices:
60+
61+
```powershell
62+
.\scripts\package_windows_prebuilt.ps1 -Package cpu -Profile balance -Jobs 16
63+
.\scripts\package_windows_prebuilt.ps1 -Package cuda -Profile balance -Jobs 16
64+
```
65+
66+
Release profiles:
67+
68+
```powershell
69+
.\scripts\package_windows_prebuilt.ps1 -Package all -Profile fast -Jobs 16
70+
.\scripts\package_windows_prebuilt.ps1 -Package all -Profile balance -Jobs 16
71+
.\scripts\package_windows_prebuilt.ps1 -Package all -Profile portable -Jobs 16
72+
```
73+
74+
Generated zips are written under `build/prebuilt`:
75+
76+
```text
77+
build/prebuilt/audiocpp-windows-cpu-balance.zip
78+
build/prebuilt/audiocpp-windows-cuda-balance.zip
79+
```
80+
81+
## Choosing a Release Profile
82+
83+
For public releases, `balance` is the recommended default. It avoids native CPU selection while still using AVX2-class kernels for reasonable performance on modern Windows machines.
84+
85+
Use `fast` only when you are comfortable with a machine-specific package. If the build machine has AVX512, the resulting binary may require AVX512.
86+
87+
Use `portable` when compatibility matters more than speed. It disables llamafile SGEMM in addition to using the baseline CPU arch, because that is the safest path for unknown user machines.
88+
89+
## Runtime Requirements for Users
90+
91+
CPU package:
92+
93+
- 64-bit Windows
94+
- Model files downloaded separately
95+
96+
CUDA package:
97+
98+
- 64-bit Windows
99+
- NVIDIA GPU with compute capability 7.5 or newer
100+
- NVIDIA driver 580 or newer
101+
- Model files downloaded separately
102+
103+
The package script copies MSVC/OpenMP runtime DLLs into both packages. The CUDA package also copies the CUDA DLLs used by this build, so users should not need to install the CUDA Toolkit or Visual Studio Build Tools.
104+
105+
The CUDA package is intended for RTX 20/30/40/50 series GPUs and similar NVIDIA datacenter GPUs. Older GPUs such as GTX 10-series Pascal cards or V100-class Volta cards are not covered by the CUDA 13 package; use the CPU package or build a separate package with an older CUDA Toolkit if those GPUs must be supported.

scripts/build_windows.ps1

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ param(
66
[switch]$ConfigureOnly,
77
[switch]$Clean,
88
[string]$CudaArchitectures = "auto",
9+
[ValidateSet("", "native", "avx2", "baseline")]
10+
[string]$CpuArch = "",
911
[ValidateSet("ON", "OFF")]
1012
[string]$NativeCpu = $null,
1113
[ValidateSet("ON", "OFF")]
@@ -219,6 +221,38 @@ function Add-MsvcEnvironment {
219221
}
220222

221223
function Resolve-CudaArchitectures {
224+
function Get-ReleaseCudaArchitectures {
225+
$nvcc = Join-Path $env:CUDA_PATH "bin\nvcc.exe"
226+
$supported = @()
227+
if (Test-Path -LiteralPath $nvcc) {
228+
$supported = & $nvcc --list-gpu-arch 2>$null
229+
}
230+
231+
$wanted = @(
232+
@{ Compute = "compute_75"; Arch = "75-virtual" },
233+
@{ Compute = "compute_80"; Arch = "80-virtual" },
234+
@{ Compute = "compute_86"; Arch = "86-real" },
235+
@{ Compute = "compute_89"; Arch = "89-real" },
236+
@{ Compute = "compute_120"; Arch = "120a-real" },
237+
@{ Compute = "compute_121"; Arch = "121a-real" }
238+
)
239+
240+
$archs = @()
241+
foreach ($item in $wanted) {
242+
if ($supported -contains $item.Compute) {
243+
$archs += $item.Arch
244+
}
245+
}
246+
if ($archs.Count -eq 0) {
247+
$archs = @("75-virtual", "80-virtual", "86-real")
248+
}
249+
return ($archs -join ";")
250+
}
251+
252+
if ($CudaArchitectures -eq "default" -or $CudaArchitectures -eq "ggml-default") {
253+
return Get-ReleaseCudaArchitectures
254+
}
255+
222256
if ($CudaArchitectures -ne "" -and $CudaArchitectures -ne "auto") {
223257
return $CudaArchitectures
224258
}
@@ -254,6 +288,57 @@ function Assert-OpenMpConfigured {
254288
}
255289
}
256290

291+
function Get-CpuArchSettings {
292+
param([AllowEmptyString()][string]$Name)
293+
294+
switch ($Name) {
295+
"" {
296+
return @{
297+
Label = "preset default"
298+
Native = $null
299+
CMakeArgs = @()
300+
}
301+
}
302+
"native" {
303+
return @{
304+
Label = "native"
305+
Native = "ON"
306+
CMakeArgs = @()
307+
}
308+
}
309+
"avx2" {
310+
return @{
311+
Label = "AVX2"
312+
Native = "OFF"
313+
CMakeArgs = @(
314+
"-DGGML_AVX=ON",
315+
"-DGGML_AVX2=ON",
316+
"-DGGML_AVX512=OFF",
317+
"-DGGML_AVX512_VBMI=OFF",
318+
"-DGGML_AVX512_VNNI=OFF",
319+
"-DGGML_AVX512_BF16=OFF",
320+
"-DGGML_AVX_VNNI=OFF"
321+
)
322+
}
323+
}
324+
"baseline" {
325+
return @{
326+
Label = "baseline"
327+
Native = "OFF"
328+
CMakeArgs = @(
329+
"-DGGML_AVX=OFF",
330+
"-DGGML_AVX2=OFF",
331+
"-DGGML_AVX512=OFF",
332+
"-DGGML_AVX512_VBMI=OFF",
333+
"-DGGML_AVX512_VNNI=OFF",
334+
"-DGGML_AVX512_BF16=OFF",
335+
"-DGGML_AVX_VNNI=OFF"
336+
)
337+
}
338+
}
339+
}
340+
}
341+
257342
function Get-PresetSettings {
258343
param([Parameter(Mandatory = $true)][string]$Name)
259344

@@ -313,10 +398,14 @@ function Get-PresetSettings {
313398
}
314399

315400
$settings = Get-PresetSettings $Preset
316-
if ($null -ne $NativeCpu) {
401+
$cpuArchSettings = Get-CpuArchSettings $CpuArch
402+
if ($null -ne $cpuArchSettings.Native) {
403+
$settings.Native = $cpuArchSettings.Native
404+
}
405+
if (-not [string]::IsNullOrEmpty($NativeCpu)) {
317406
$settings.Native = $NativeCpu
318407
}
319-
if ($null -ne $Llamafile) {
408+
if (-not [string]::IsNullOrEmpty($Llamafile)) {
320409
$settings.Llamafile = $Llamafile
321410
}
322411
$isCudaPreset = $settings.EnableCuda -eq "ON"
@@ -364,6 +453,7 @@ Write-Host "Windows SDK: $(Split-Path $mt -Parent)"
364453
if ($arch -ne "") {
365454
Write-Host "CUDA architectures: $arch"
366455
}
456+
Write-Host "CPU architecture profile: $($cpuArchSettings.Label)"
367457
Write-Host "Native CPU optimization: $($settings.Native)"
368458
Write-Host "llamafile SGEMM: $($settings.Llamafile)"
369459

@@ -400,6 +490,7 @@ $configureArgs = @(
400490
"-DENGINE_ENABLE_LLAMAFILE=$($settings.Llamafile)",
401491
"-DENGINE_BUILD_TESTS=$($settings.BuildTests)"
402492
)
493+
$configureArgs += $cpuArchSettings.CMakeArgs
403494
if ($settings.CFlagsDebug -ne "") {
404495
$configureArgs += "-DCMAKE_C_FLAGS_DEBUG=$($settings.CFlagsDebug)"
405496
}
@@ -414,6 +505,8 @@ if ($isCudaPreset) {
414505
}
415506
if ($isCudaPreset -and $arch -ne "") {
416507
$configureArgs += "-DCMAKE_CUDA_ARCHITECTURES=$arch"
508+
} elseif ($isCudaPreset) {
509+
$configureArgs += @("-U", "CMAKE_CUDA_ARCHITECTURES")
417510
}
418511

419512
Invoke-Checked $cmake $configureArgs

0 commit comments

Comments
 (0)