Spaces:
Running

notmax123 Claude Opus 5 (1M context) commited on
Commit
f2d1b4a
Β·
1 Parent(s): 92bfbd1

Split the CPU-onnxruntime dependencies into pre-requirements.txt

Browse files

Pinning renikud-plus to the PR branch was necessary but not sufficient: ruphon
and ruaccent each declare `onnxruntime` too. Those are the Russian front end,
which means the Russian support added in this series is itself part of what has
been holding the Space on CPU.

Three packages pulling the CPU wheel cannot be ordered around inside one
requirements file, because pip installs topologically rather than in file
order. Two pip passes can: HF Spaces installs pre-requirements.txt first, so
putting the CPU-build dependencies there leaves onnxruntime-gpu as the last
thing to write onnxruntime/.

Confirmed on linux/amd64 with the real package set:
after phase 1 (ruaccent, ruphon, renikud): CUDA absent
after phase 2 (onnxruntime-gpu): ['Tensorrt', 'CUDA', 'CPU']

transformers moves along with them β€” ruphon's tokenizer imports symbols that
transformers 5 removed, so the pin has to apply in the pass that installs it.

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

Files changed (2) hide show
  1. pre-requirements.txt +17 -0
  2. requirements.txt +11 -13
pre-requirements.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Installed BEFORE requirements.txt, in a separate pip invocation.
2
+ #
3
+ # Everything here declares a dependency on `onnxruntime` β€” the CPU build β€” and
4
+ # that wheel unpacks into the same `onnxruntime/` directory as `onnxruntime-gpu`.
5
+ # Whichever pip writes last wins, and within a single requirements file the
6
+ # install order is topological rather than file order, so there is no way to
7
+ # spell "GPU last" in one pass. Two passes give us the ordering: these first,
8
+ # then `onnxruntime-gpu` from requirements.txt overwrites the CPU build.
9
+ #
10
+ # Get this wrong and nothing errors β€” CUDAExecutionProvider simply disappears
11
+ # and the Space runs its graphs on CPU on ZeroGPU hardware.
12
+ #
13
+ # transformers is pinned here rather than in requirements.txt because ruphon's
14
+ # bundled tokenizer imports symbols that transformers 5 removed.
15
+ ruaccent
16
+ ruphon
17
+ transformers<5
requirements.txt CHANGED
@@ -21,22 +21,20 @@ bluecodec @ git+https://github.com/maxmelichov/blue-codec.git
21
  # Switch back to `renikud-plus>=0.4.0` once that is merged and published β€” a
22
  # branch reference breaks if the branch is renamed or deleted.
23
  renikud-plus @ git+https://github.com/maxmelichov/RenikudPlus.git@onnxruntime-optional
24
- # Russian front end (RUAccent stress + RUPhon phonemization). espeak-ng is not
25
- # an option for ru β€” see g2p/russian_g2p.py.
26
- ruaccent
27
- ruphon
28
- transformers<5
29
 
30
  # ---------------------------------------------------------------------------
31
- # Keep this the only thing that installs an ONNX Runtime.
32
  #
33
- # renikud-plus <=0.3.0 also depends on `onnxruntime` (the CPU build), and both
34
- # wheels unpack into the same `onnxruntime/` directory, so whichever pip writes
35
- # last wins. It wrote the CPU one last (positions 65 vs 66 in the build log),
36
- # CUDAExecutionProvider disappeared, and ORT quietly ran the graph on CPU on
37
- # ZeroGPU hardware. Ordering this file does NOT fix it β€” pip installs in
38
- # topological order, not file order. That is why renikud-plus is pinned to the
39
- # branch above rather than to PyPI.
40
  # ---------------------------------------------------------------------------
41
  onnxruntime-gpu>=1.24; sys_platform == "linux"
42
  onnxruntime>=1.24; sys_platform != "linux"
 
21
  # Switch back to `renikud-plus>=0.4.0` once that is merged and published β€” a
22
  # branch reference breaks if the branch is renamed or deleted.
23
  renikud-plus @ git+https://github.com/maxmelichov/RenikudPlus.git@onnxruntime-optional
24
+ # The Russian front end (RUAccent + RUPhon) lives in pre-requirements.txt β€”
25
+ # both declare a CPU `onnxruntime`, so they have to be installed in an earlier
26
+ # pip pass than the GPU wheel below. See that file for the full reason.
 
 
27
 
28
  # ---------------------------------------------------------------------------
29
+ # This must be the LAST thing that writes to onnxruntime/.
30
  #
31
+ # `onnxruntime` and `onnxruntime-gpu` unpack into the same directory, so
32
+ # whichever pip writes last wins. Within a single requirements file the order is
33
+ # topological, not file order, so this cannot be arranged in one pass β€” the
34
+ # CPU-build dependencies are split into pre-requirements.txt to force it.
35
+ #
36
+ # There is no error when this goes wrong: CUDAExecutionProvider just disappears
37
+ # and the graphs run on CPU on ZeroGPU hardware.
38
  # ---------------------------------------------------------------------------
39
  onnxruntime-gpu>=1.24; sys_platform == "linux"
40
  onnxruntime>=1.24; sys_platform != "linux"