-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(depends): allow a CPU-only dependency resolve, opt-in #1708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -674,9 +674,34 @@ def _save_hash(hash_file: str, hash_value: str): | |
| f.write(hash_value) | ||
|
|
||
|
|
||
| def _cpu_only() -> bool: | ||
| """True when this host should resolve CPU-only wheels. | ||
|
|
||
| Opt-in via ``ROCKETRIDE_CPU_ONLY_DEPS=1``. Deliberately NOT auto-detected: | ||
| guessing "no GPU visible, therefore CPU" would silently downgrade a machine | ||
| whose driver simply is not loaded yet, and a silent downgrade of an | ||
| inference host is far worse than an oversized install. | ||
| """ | ||
| return os.environ.get('ROCKETRIDE_CPU_ONLY_DEPS', '').strip().lower() in ('1', 'true', 'yes') | ||
|
|
||
|
|
||
| def _combine_requirements(file_paths: list[str], output_path: str): | ||
| """Concatenate all requirement files into one.""" | ||
| with open(output_path, 'w', encoding='utf-8') as out: | ||
| if _cpu_only(): | ||
| # PyPI's default `torch` wheel is the CUDA build, which drags in | ||
| # ~13 nvidia-* packages plus triton. On the cloud ALB that measured | ||
| # 6.6 GB of the pod's 8.2 GB site-packages — on an m7i-flex.large | ||
| # with no GPU, no /dev/nvidia*, and no models (inference goes out to | ||
| # the H100). It was downloaded and written on every pod start and | ||
| # never once executed. See rocketride-server #1697. | ||
| # | ||
| # Pointing at the CPU index makes torch resolve to +cpu (~200 MB) | ||
| # and the nvidia-* packages are never selected at all. Verified with | ||
| # `uv pip compile` over the four nodes that pull torch transitively: | ||
| # 119 packages / 13 nvidia-* -> 105 packages / 0 nvidia-*. | ||
| out.write('# CPU-only resolve: ROCKETRIDE_CPU_ONLY_DEPS is set.\n') | ||
| out.write('--extra-index-url https://download.pytorch.org/whl/cpu\n\n') | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| for path in file_paths: | ||
| out.write(f'# Source: {path}\n') | ||
| with open(path, 'r', encoding='utf-8') as inp: | ||
|
|
@@ -782,8 +807,17 @@ def _write_excludes_file() -> str: | |
| """ | ||
| excludes_path = os.path.join(engine_cache_dir(), 'excludes.txt') | ||
| excludes = 'uv\n' | ||
| if platform.system() != 'Darwin': | ||
| # The onnxruntime exclusion keys on OS, which is not the question being | ||
| # asked. "Not a Mac" was used as a proxy for "has CUDA", and it is wrong on | ||
| # every Linux box without a GPU — including the cloud ALB, where it forces | ||
| # the GPU build and blocks the CPU one from ever being installed. Excluding | ||
| # it there would defeat the CPU-only resolve above, so honour that flag. | ||
| if platform.system() != 'Darwin' and not _cpu_only(): | ||
| excludes += 'onnxruntime\n' | ||
| elif _cpu_only(): | ||
| # Mirror image: on a CPU-only host the GPU build is the one that must | ||
| # not win, for the same clobbering reason the original comment gives. | ||
| excludes += 'onnxruntime-gpu\n' | ||
|
Comment on lines
+810
to
+820
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the file and inspect the relevant function and surrounding documentation/tests.
sed -n '760,840p' packages/server/engine-lib/rocketlib-python/lib/depends.py
printf '\n--- _cpu_only definition/usages ---\n'
rg -n "def _cpu_only|_cpu_only\(|cpu_only|onnxruntime-gpu|excludes" packages/server/engine-lib/rocketlib-python/lib/depends.py
printf '\n--- related docs/comments ---\n'
rg -n -C 3 "CUDA|cpu|Darwin|onnxruntime-gpu|onnxruntime" packages/server/engine-lib/rocketlib-python/lib/depends.py packages/server/engine-lib -g '*.py' -g '*.md' | head -n 200Repository: rocketride-org/rocketride-server Length of output: 15816 Keep the CPU-only exclusion OS-gated as documented.
🧰 Tools🪛 ast-grep (0.45.0)[warning] 820-820: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) 🤖 Prompt for AI Agents |
||
| with open(excludes_path, 'w', encoding='utf-8') as f: | ||
| f.write(excludes) | ||
| return excludes_path | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.