This file is a focused walkthrough for building and running VoxCPM.cpp with the ggml CUDA backend.
- Build the project so
--backend cudaworks. - Keep a separate build directory from CPU builds.
- Verify both the TTS example and the OpenAI-compatible server on CUDA.
For the CUDA service path, current request budgeting is:
seq_len <= 256: output-pool fast path, decode cap 128 steps257-512: fallback path, decode cap 96 steps>512: chunked prefill path, decode cap 64 steps
- NVIDIA GPU
- NVIDIA driver installed
- CUDA toolkit installed
cmake,makeorninja, and a C++ toolchainffmpegif you wantresponse_format=opus
If you are unsure about your GPU architecture, check it first. The common values in this repo are:
86for many RTX 30-series GPUs89for many RTX 40-series GPUs
Use a separate build directory:
cmake -B build-cuda \
-DVOXCPM_CUDA=ON \
-DVOXCPM_BUILD_BENCHMARK=OFF \
-DVOXCPM_BUILD_TESTS=ON \
-DVOXCPM_ENABLE_MP3=ON \
-DVOXCPM_ENABLE_OPUS=ON \
-DCMAKE_CUDA_ARCHITECTURES=89Notes:
-DVOXCPM_CUDA=ONenables the ggml CUDA backend.- Keep
build-cudaseparate frombuildso CPU and CUDA artifacts do not overwrite each other. - If your GPU is not an RTX 40-series card, replace
89with the architecture that matches your card. VOXCPM_ENABLE_MP3andVOXCPM_ENABLE_OPUSare independent of CUDA. Leave themONunless you want to disable those audio formats.
If you want a smaller configure step for a quick inference-only build, you can also disable tests:
cmake -B build-cuda \
-DVOXCPM_CUDA=ON \
-DVOXCPM_BUILD_BENCHMARK=OFF \
-DVOXCPM_BUILD_TESTS=OFF \
-DVOXCPM_ENABLE_MP3=ON \
-DVOXCPM_ENABLE_OPUS=ON \
-DCMAKE_CUDA_ARCHITECTURES=89cmake --build build-cuda -j8If the configure step was already done and you only changed source files, rerun the same build command.
Confirm the CUDA-enabled binaries exist:
ls build-cuda/examples/voxcpm_tts
ls build-cuda/examples/voxcpm-serverUse the CUDA backend explicitly:
./build-cuda/examples/voxcpm_tts \
--model-path ./models/voxcpm1.5-q4_k-audiovae-f16.gguf \
--prompt-audio ./examples/tai_yi_xian_ren.wav \
--prompt-text "对,这就是我,万人敬仰的太乙真人。" \
--text "大家好,我现在正在大可奇奇体验AI科技。" \
--output ./out.wav \
--backend cuda \
--threads 8If you want to test a more typical generation path:
./build-cuda/examples/voxcpm_tts \
--model-path ./models/voxcpm1.5-q4_k-audiovae-f16.gguf \
--prompt-audio ./examples/tai_yi_xian_ren.wav \
--prompt-text "对,这就是我,万人敬仰的太乙真人。" \
--text "大家好,我现在正在大可奇奇体验AI科技。" \
--output ./out.wav \
--backend cuda \
--threads 8 \
--inference-timesteps 10 \
--cfg-value 2.0Start the OpenAI-compatible server:
./build-cuda/examples/voxcpm-server \
--host 127.0.0.1 \
--port 8080 \
--model-path ./models/voxcpm1.5-q4_k-audiovae-f16.gguf \
--model-name voxcpm-1.5 \
--threads 8 \
--backend cuda \
--voice-dir ./runtime/voices \
--max-queue 8 \
--max-decode-steps 512 \
--output-sample-rate 24000 \
--disable-authFor long text, set --max-decode-steps high enough for the expected output length. Leaving it unset or using 0 keeps the conservative CUDA service defaults.
Register a voice:
curl -X POST http://127.0.0.1:8080/v1/voices \
-F "id=taiyi" \
-F "text=对,这就是我,万人敬仰的太乙真人。" \
-F "audio=@./examples/tai_yi_xian_ren.wav"Request mp3:
curl -X POST http://127.0.0.1:8080/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{
"model": "voxcpm-1.5",
"input": "大家好,我现在正在大可奇奇体验AI科技。",
"voice": "taiyi",
"response_format": "mp3",
"stream_format": "audio"
}' \
--output ./voxcpm_taiyi.mp3Request opus:
curl -X POST http://127.0.0.1:8080/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{
"model": "voxcpm-1.5",
"input": "大家好,我现在正在大可奇奇体验AI科技。",
"voice": "taiyi",
"response_format": "opus",
"stream_format": "audio"
}' \
--output ./voxcpm_taiyi.opusIf your CUDA build directory got stale, it is often easiest to delete only that build tree and reconfigure:
rm -rf build-cuda
cmake -B build-cuda \
-DVOXCPM_CUDA=ON \
-DVOXCPM_BUILD_BENCHMARK=OFF \
-DVOXCPM_BUILD_TESTS=ON \
-DVOXCPM_ENABLE_MP3=ON \
-DVOXCPM_ENABLE_OPUS=ON \
-DCMAKE_CUDA_ARCHITECTURES=89
cmake --build build-cuda -j8- Build config finishes but CUDA binaries do not appear:
- Make sure you ran
cmake --build build-cuda, notbuild.
- Make sure you ran
--backend cudafails at runtime:- Check that the NVIDIA driver and CUDA toolkit match your system.
- Make sure the GPU architecture passed to
CMAKE_CUDA_ARCHITECTURESmatches your card.
response_format=opusreturns 501:ffmpegwas not found when CMake configured the build, or the Opus path was disabled.
response_format=mp3returns 501:- Reconfigure with
-DVOXCPM_ENABLE_MP3=ON.
- Reconfigure with
CUDA_VISIBLE_DEVICESin your systemd unit only selects which GPU the process can see.- It does not affect
response_format,mp3/opusencoding, or OpenAI-compatible audio MIME selection.
- It does not affect
- If an OpenAI-compatible client assumes 24 kHz PCM playback, start
voxcpm-serverwith--output-sample-rate 24000.pcmresponses have no embedded sample-rate header, so the server-side output rate must match the client expectation.- The same override also applies to
wav,mp3, andopus.
- If long requests always stop at the same
generated_framesvalue, increase--max-decode-steps.- The default CUDA service budget is intentionally conservative to bound latency and memory.
- For example,
--max-decode-steps 512allows longer synthesis while still keeping a fixed upper bound.
- Configure
build-cudawith-DVOXCPM_CUDA=ON. - Build with
cmake --build build-cuda -j8. - Run
voxcpm_ttswith--backend cuda. - Run
voxcpm-serverwith--backend cuda. - Test
mp3andopusrequests.