Skip to content

Document reusing image-baked libraries with hf jobs uv run#2517

Merged
davanstrien merged 5 commits into
mainfrom
jobs-vllm-image-recipe
Jun 4, 2026
Merged

Document reusing image-baked libraries with hf jobs uv run#2517
davanstrien merged 5 commits into
mainfrom
jobs-vllm-image-recipe

Conversation

@davanstrien

@davanstrien davanstrien commented Jun 2, 2026

Copy link
Copy Markdown
Member

The Popular Images page shows how to point Jobs at the vLLM/TRL images, but not how
to actually reuse the libraries baked into them. hf jobs uv run resolves a script's
deps from PyPI by default, so a script importing vllm gets a fresh PyPI install rather
than the image's prebuilt, CUDA-matched build — which can fail at startup with
RuntimeError: Could not find nvcc (FlashInfer trying to JIT-compile a kernel).

This adds a short "Reusing image-baked libraries with uv run" section covering:

  • the --python + PYTHONPATH recipe, with vLLM as the worked example
  • a cpu-basic probe to find the interpreter / site-packages paths for any image
  • that it applies only to uv run, not generic hf jobs run

Note

Low Risk
Documentation-only change to the Hub Jobs popular images page; no runtime or product code affected.

Overview
Expands Popular Images with guidance for GPU Jobs: new tips on using --image for a CUDA-matched stack, and a section Using framework images for GPU libraries that explains why the default uv image can hit nvcc / FlashInfer failures and how framework images fix that.

Adds an optional workflow to reuse image-baked Python builds via --python and PYTHONPATH, a cpu-basic probe command to discover paths per image, and notes on layout differences (e.g. vLLM vs Unsloth) plus upstream uv limitations.

Reviewed by Cursor Bugbot for commit 1191e76. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a "Reusing image-baked libraries with uv run" section to the Popular Images
page. By default `hf jobs uv run` resolves a script's dependencies from PyPI and
does not use the libraries already in the image; for images that ship prebuilt,
CUDA-matched builds (vLLM, PyTorch, FlashInfer) you usually want to reuse them
via `--python` + `PYTHONPATH`.

The section covers:
- the two-flag recipe, with vLLM as the worked example
- a cpu-basic probe to discover the interpreter / site-packages paths per image
- the `RuntimeError: Could not find nvcc` symptom (FlashInfer JIT) as one example
- that this applies only to `uv run`, not generic `hf jobs run`, plus the upstream
  uv issue (astral-sh/uv#7999)

Also adds a short cross-link tip in the vLLM section.
@davanstrien
davanstrien requested a review from lhoestq June 2, 2026 08:18
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@davanstrien
davanstrien requested a review from pcuenca June 2, 2026 08:34

@lhoestq lhoestq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ! I hope they can ship uv run --system-siye-packages soon

Comment thread docs/hub/jobs-popular-images.md Outdated
davanstrien and others added 2 commits June 3, 2026 17:53
Address review: relocate the detailed "Reusing image-baked libraries
with uv run" section to the end of the page, and add a warning callout
near the top so the naive `hf jobs uv run` failure mode is flagged
before the framework list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GPU-tested the claims on HF Jobs (l4x1/a100, Qwen2.5-0.5B):
- Reproduced `Could not find nvcc` ONLY on the default uv image
  (no CUDA toolkit). With --image vllm/vllm-openai it works, because
  the image provides nvcc + the CUDA system stack.
- So the real fix is using the framework image, not the --python +
  PYTHONPATH recipe; "usually all you need" is just --image.
- Reuse via PYTHONPATH does not skip the PyPI install (same ~3.5GB
  downloaded), so it's not a speed-up — demoted to an optional
  sub-section for ABI/CUDA-mismatch cases.

Lead the section with the system-stack point and the nvcc repro;
keep the probe (paths/uv vary per image, verified across vLLM, sglang,
unsloth, trl, transformers, axolotl).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread docs/hub/jobs-popular-images.md Outdated
Comment thread docs/hub/jobs-popular-images.md Outdated
@davanstrien

Copy link
Copy Markdown
Member Author

Will merge for now. can iterate more on this / hopefully simplify approach if uv add supports for using system packages in scripts

@davanstrien
davanstrien merged commit c28d618 into main Jun 4, 2026
3 checks passed
@davanstrien
davanstrien deleted the jobs-vllm-image-recipe branch June 4, 2026 08:59
Comment on lines +42 to +47
GPU libraries like vLLM need more than their Python package — they need a matching system
environment: the CUDA toolkit (including `nvcc`), system libraries like NCCL and cuDNN, and so
on. If you omit `--image`, `hf jobs uv run` uses the default uv image
(`ghcr.io/astral-sh/uv:python3.12-bookworm`), a bare Python base with no CUDA toolkit. Your
dependencies still install from PyPI, but at runtime a library that needs the toolkit can fail —
for example FlashInfer's sampler JIT-compiles a kernel and aborts with:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But passing --image is what we already do in the existing version of the page, isn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg too late lol; no worries though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants