Split the CPU-onnxruntime dependencies into pre-requirements.txt
Browse filesPinning 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
- pre-requirements.txt +17 -0
- requirements.txt +11 -13
|
@@ -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
|
|
@@ -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
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
ruphon
|
| 28 |
-
transformers<5
|
| 29 |
|
| 30 |
# ---------------------------------------------------------------------------
|
| 31 |
-
#
|
| 32 |
#
|
| 33 |
-
#
|
| 34 |
-
#
|
| 35 |
-
#
|
| 36 |
-
#
|
| 37 |
-
#
|
| 38 |
-
#
|
| 39 |
-
#
|
| 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"
|