[Bug] CUDA VRAM grows without bound (doubles repeatedly) with 1.13.5+cuda12.cudnn9.onnxruntime1.27.1, flat with 1.13.4+cuda12.cudnn9

Author: life-0Created Sep 24, 2026Updated Sep 25, 2026
Labelsbug

Describe the bug

With sherpa-onnx==1.13.5+cuda12.cudnn9.onnxruntime1.27.1 (bundled ONNX Runtime reports 1.27.1), a long-lived Python service holding 6 OfflineTts instances (matcha-icefall-zh-en, provider="cuda") leaks GPU memory monotonically until OOM. The process memory roughly doubles every time it grows: 1.6 GB -> 3.2 -> 6.4 -> 12.8 -> 25.6 -> 49.0 GB in about 6 minutes, and after the load stops the process still holds 48.9 GB.

The identical code, model and load with sherpa-onnx==1.13.4+cuda12.cudnn9 (no .onnxruntime* suffix in the wheel name) stays completely flat. Only the wheel differs.

Environment

  • sherpa-onnx (reproduces): 1.13.5+cuda12.cudnn9.onnxruntime1.27.1, bundled ONNX Runtime = 1.27.1
  • sherpa-onnx (no growth): 1.13.4+cuda12.cudnn9
  • Python 3.12.3, Ubuntu 24.04 (kernel 6.8.0-31-generic), x86_64
  • GPU: NVIDIA A800 80GB PCIe, driver 570.124.06, CUDA 12.8 runtime, cuDNN 9 (device_id=0)
  • Model: matcha-icefall-zh-en (model-steps-3.onnx + vocos-16khz-univ.onnx)
  • OfflineTts created with num_threads=2, provider="cuda", noise_scale=0 (from the model's config.json)
  • 6 instances kept in a queue.Queue pool, created once at startup and reused forever
  • Every request does tts.generate(text, sid=0, speed=1.0)
  • Text: random sentences from a 14-sentence Chinese car-assistant corpus, 5-35 characters

Steps to reproduce

  1. pip install "sherpa-onnx==1.13.5+cuda12.cudnn9.onnxruntime1.27.1" -f https://k2-fsa.github.io/sherpa/onnx/cuda-cn.html
  2. Start a service that creates 6 OfflineTts instances as above and serves them over TLS (http.server.ThreadingHTTPServer); each request calls generate(text, sid=0, speed=1.0).
  3. Drive it with concurrent clients sending random sentences from the corpus above. (In our case the clients are Android devices over TLS, but any multithreaded HTTP client should do.)
  4. Watch the GPU memory of the service process: nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader,nounits

Observed (5 s sampling, attached vram_1.13.5_ttsonly.csv):

15:23:16   tts 1.58 GB   <- service just started, 6 instances warmed up
15:23:37   tts 3.97 GB
15:23:48   tts 6.95 GB
15:24:14   tts 12.97 GB
15:25:09   tts 24.00 GB
15:27:03   tts 32.95 GB
15:29:01   tts 49.02 GB
15:29:07   tts 48.94 GB  <- load stopped (process CPU 0%), memory NOT released

Note the plateaus at roughly 3.2 / 6.4 / 12.8 / 25.6 / 49 GB: the arena looks like it doubles (kNextPowerOfTwo) whenever it needs a bit more, and never returns memory.

A second run of the same wheel under a mixed TTS+ASR+LLM load grew 1.78 GB -> 22.98 GB in under 3 minutes (attached vram_1.13.5_mixed.csv).

What we checked, to rule out our own code

  • Serial control: 1 instance, 1 thread, 569 generate() calls in 124 s -> 652 MB to 740 MB (+88 MB) and then flat (attached serial_control_1.13.5.txt). So there is no per-call leak in the Python layer, and repeatedly synthesizing the same corpus does not grow memory.
  • The pool size is fixed; instances are never re-created, and the text length range is bounded (5-35 chars).
  • Only the wheel was changed (1.13.5+ORT 1.27.1 -> 1.13.4), nothing else, and the growth disappears.
  • Possibly useful observation: a minimal in-process harness (6 instances, 6 worker threads, each thread pinned to its own instance, ~1300 synthesis/min) did not grow in the 46 s we let it run, while the service (same 6 instances, but shared by many client threads, TTS process at ~600% CPU) grows within seconds. So the number of distinct threads calling generate() may be part of the trigger.

Additional context

session.cc, case Provider::kCUDA:, only sets device_id and cudnn_conv_algo_search. Keys read from a provider config file are not forwarded to the CUDA EP, so there is no way to set arena_extend_strategy, gpu_mem_limit or cudnn_conv_use_max_workspace from Python as a workaround.

Requests:

  1. Please pin/rebuild the +cuda12.cudnn9 wheels against the ONNX Runtime version that 1.13.4 uses (which does not show this), or against a fixed ORT release; and/or
  2. Forward provider-config keys to AppendExecutionProvider_CUDA_V2 + UpdateCUDAProviderOptions, so arena_extend_strategy=kSameAsRequested / gpu_mem_limit can be used as a workaround. There is precedent: #3503 (merged) exposed EnableCpuMemArena / EnableMemPattern through the provider config file for the CPU arena -- the CUDA EP arena has no equivalent.

If 1.13.8 (which ships ONNX Runtime 1.28.2 per #3935) already behaves correctly, please just tell us and we'll upgrade instead.

Happy to test a candidate wheel on this machine and report the VRAM curve.

vram_1135_ttsonly.csv vram_1135_ttsonly.txt vram_mix.csv

engines.py tts_service.py

monitor.py