Spaces:
Running

notmax123 Claude Opus 5 (1M context) commited on
Commit
375e0ce
·
1 Parent(s): 090cf73

Make the GPU the default on ZeroGPU

Browse files

With the CUDA provider configured properly the earlier conclusion inverts.
Warm in-window synthesis is 0.10s against ~0.4s on CPU, and end to end:

ru 3.11s -> 0.38s median (8x)
he 0.63s -> 0.48s
en 0.46s -> 0.47s

Russian was the complaint and Russian is where it pays. The 9.3s I measured
before was ORT brute-forcing convolution algorithms with the default
EXHAUSTIVE search, not the per-request session rebuild I blamed it on; the
rebuild is real but only costs ~0.85s.

So invert the flag: GPU by default, BLUE_ZEROGPU_ONNX=0 to opt out. The
remaining cost is variance rather than throughput — when ZeroGPU recycles the
worker that request rebuilds and takes ~3-4s, so a workload of rare one-off
requests may still prefer CPU.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138DB6F6YxWtYWy7WNaLAsU

Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -2372,15 +2372,18 @@ def _gpu_backend() -> str:
2372
  global _GPU_BACKEND
2373
  if _GPU_BACKEND is not None:
2374
  return _GPU_BACKEND
2375
- if _ZERO_GPU and not _env_truthy("BLUE_ZEROGPU_ONNX"):
2376
- # ONNX Runtime is a poor fit for ZeroGPU and the numbers are not close.
2377
- # ZeroGPU hands each call a fresh forked worker, and an ORT CUDA session
2378
- # cannot be built in the parent and inherited the way ZeroGPU packs
2379
- # torch weights — so the session is rebuilt every request. Measured on
2380
- # this Space, same text: 9.3 s through the GPU window against 0.5 s
2381
- # running the CPU session in-process, with the graph rebuilt all five
2382
- # times out of five. CPU also spends no GPU quota and cannot raise
2383
- # AcceleratorError. Set BLUE_ZEROGPU_ONNX=1 to opt back in.
 
 
 
2384
  _GPU_BACKEND = "cpu"
2385
  elif not _ZERO_GPU:
2386
  _GPU_BACKEND = "cuda" if TTS.on_cuda else "cpu"
 
2372
  global _GPU_BACKEND
2373
  if _GPU_BACKEND is not None:
2374
  return _GPU_BACKEND
2375
+ if _ZERO_GPU and os.environ.get("BLUE_ZEROGPU_ONNX", "1").strip().lower() in {
2376
+ "0", "false", "no", "off",
2377
+ }:
2378
+ # Opt-out. GPU is the default because it wins where it matters once the
2379
+ # CUDA provider is configured properly (see the provider options in
2380
+ # BlueTTS.__init__ — the earlier 9 s figure was ORT brute-forcing
2381
+ # convolution algorithms, not the session rebuild I first blamed).
2382
+ # Warm, in-window synthesis is 0.10 s against ~0.4 s on CPU; end to end,
2383
+ # Russian goes 3.11 s -> 0.38 s median. The cost is variance: when
2384
+ # ZeroGPU recycles the worker the session is rebuilt and that request
2385
+ # takes ~3-4 s, so a workload of rare single requests may still prefer
2386
+ # CPU. Set BLUE_ZEROGPU_ONNX=0 for that.
2387
  _GPU_BACKEND = "cpu"
2388
  elif not _ZERO_GPU:
2389
  _GPU_BACKEND = "cuda" if TTS.on_cuda else "cpu"