Установка
SKILL.md
Serving Image Selection
The serving container is the single thing most likely to break a SageMaker deployment that "looked correct on paper". Wrong container, stale tag, or the wrong AMI — all produce the same opaque Failed to pass health check error.
Rule zero: HuggingFace images always win
When both a HuggingFace-curated family (huggingface-vllm, huggingface-vllm-omni, huggingface-sglang, tei, huggingface-pytorch-inference) and a generic family (vllm, vllm-omni, sglang, djl-inference) can serve the model, the HuggingFace one is mandatory, not preferred. The only valid reasons to use a generic image:
- Verified incompatibility — the model needs an architecture/modality/feature no available HuggingFace tag supports, confirmed against the catalog (not assumed).
- No HuggingFace tag exists in the target region and mirroring is not an option.
- The HuggingFace image is in "Known-broken images" below.
A newer version number on the generic repo is not a reason. The AWS vllm repo often publishes a higher vLLM version than huggingface-vllm; an older-but-compatible huggingface-vllm tag still wins. "Latest vLLM" is not a requirement anyone stated — compatibility with the model is. If you fall back, record in the deployment log which of the three reasons applied.
Where image URIs come from
Primary source: AWS's official Deep Learning Containers catalog.
URL: https://aws.github.io/deep-learning-containers/reference/available_images/
This page is AWS-maintained and lists every image family with example URIs, tags, CUDA versions, Python versions, and platform (SageMaker vs EC2/ECS/EKS). When picking a URI for a deployment, read it from this page directly — copy the example URL, substitute <region> with the user's region, and pass it to deploy.py --image-uri.
The example URLs use 763104351884 as the account ID for most regions. A few regions use different accounts (e.g. eu-south-1 uses 692866216735). Check the Region Availability page when in doubt.
Exception: none currently. Every image family used by this workflow is now on the AWS catalog page (TEI was added in late 2026). If you encounter a new family that isn't there, mirror it via mirror_image.py and pass the resulting URI directly.
Quick decision
| Model | Container family | How to get the URI |
|---|---|---|
| HuggingFace text-generation LLM (Llama, Qwen, Mistral, etc.) | HuggingFace vLLM | AWS catalog → "HuggingFace vLLM Inference" (ECR repo huggingface-vllm) |
| Same as above, multimodal | HuggingFace vLLM-Omni | AWS catalog → "HuggingFace vLLM-Omni Inference" (ECR repo huggingface-vllm-omni) |
| HuggingFace embeddings | TEI | AWS catalog → "HuggingFace Text Embeddings Inference" |
Encoder / cross-encoder rerankers (BERT-family *ForSequenceClassification) | TEI | Same as embeddings |
| Generative rerankers (causal-LM, e.g. Qwen3-Reranker) | HuggingFace vLLM | Same as text-generation LLMs — not TEI, see "Rerankers: TEI or vLLM?" |
| Text-to-image / diffusion (Stable Diffusion, FLUX) | DJL Inference | AWS catalog → "DJL Inference" — not HF Inference Toolkit, see "Known-broken images" |
| HuggingFace classifiers, NER, QA, summarization | HF Inference Toolkit (CPU) | AWS catalog → "HuggingFace PyTorch Inference"; GPU tags currently broken — see "Known-broken images" |
| User specifically wants SGLang | HuggingFace SGLang | AWS catalog → "HuggingFace SGLang Inference" |
No compatible huggingface-vllm tag (verified incompatibility or region gap — see "Rule zero") | vLLM (AWS) | AWS catalog → "vLLM" section — fallback only, never for version freshness |
| User specifically wants DJL-LMI | DJL Inference | AWS catalog → "DJL Inference" |
| Amazon Nova | SageMaker JumpStart | Use JumpStart, not raw endpoint creation |
| Custom inference code | BYOC | User provides URI |
HuggingFace-curated DLCs are mandatory when one is compatible (see "Rule zero"). huggingface-vllm is layered directly on the AWS vLLM DLC — identical SM_VLLM_* env contract and the same cu130 AMI rule — and adds current transformers, current huggingface_hub + hf_xet (avoids the XET-CDN 403 download failures older images hit), and HF performance defaults. It is also what SageMaker SDK v3 auto-routes to. The AWS vllm image is a compatibility escape hatch only; it usually shows a higher vLLM version than huggingface-vllm, and that is not a reason to pick it.
Do not use TGI. Text Generation Inference is archived. Models released after the archive (Qwen3 most famously) fail ping health checks on TGI. Use vLLM instead. (The SageMaker SDK v3 agrees: since PR #5960, June 2026, its ModelBuilder auto-routes text-generation to the HuggingFace vLLM DLC and multimodal tasks to HuggingFace vLLM-Omni.)
Full reasoning for each family in references/model-to-image.md.
Rerankers: TEI or vLLM?
"Reranker" covers two very different architectures, and picking wrong wastes a full endpoint-creation cycle (~20 min) before TEI rejects the model:
- Encoder cross-encoders (BAAI/bge-reranker-*, mixedbread, most
sentence-transformersrerankers) — BERT-family models with a classification head.config.jsonhasarchitectures: [..ForSequenceClassification]on a TEI-supported encoder type. → TEI. - Generative rerankers (Qwen/Qwen3-Reranker-*, and similar causal-LM judges) — decoder LLMs that score relevance via the logprob of a yes/no token.
config.jsonhasarchitectures: [..ForCausalLM]. → HuggingFace vLLM, deployed exactly like a text-generation LLM. TEI will load the architecture then reject theclassifiermodel type (Qwen3 support in TEI is embeddings-only). Invocation pattern (raw completions API,max_tokens=1, logprobs scoring) is inhf-cloud-sagemaker-production-defaults.
Preflight before creating any resources — one HTTP GET settles it:
curl -s https://huggingface.co/<model-id>/raw/main/config.json
# "architectures": ["Qwen3ForCausalLM"] → vLLM
# "architectures": ["XLMRobertaForSequenceClassification"] → TEI
For TEI also confirm the (architecture, task) pair: an architecture appearing in TEI's supported list means embeddings support, not necessarily classification/reranking support.
Heads-up: SageMaker SDK v3 (PR #5960) routes the text-ranking task to TEI unconditionally — correct for cross-encoders, wrong for generative rerankers. Don't treat the SDK's routing as evidence that TEI can serve a given reranker.
Workflow
For every family: read the URI from the AWS catalog page.
- Open https://aws.github.io/deep-learning-containers/reference/available_images/
- Find the section for the right family (e.g. "HuggingFace vLLM Inference" for HuggingFace LLMs, "HuggingFace Text Embeddings Inference" for embeddings)
- Pick the newest row marked
SageMakerfor the platform column — newest within that family. Do not switch to another family's section because it lists a higher engine version (see "Rule zero") - Substitute
<region>with the user's region (fromhf-cloud-aws-context-discovery) - For vLLM: also check the AMI requirement (see "vLLM AMI requirement" below)
- Pass the URI to
deploy.py --image-uri(real-time) ordeploy_async.py --image-uri(async)
TEI: pick the right variant
The TEI catalog row lists two URIs — GPU (tei repo) and CPU (tei-cpu repo). Pick based on the instance type:
ml.g*,ml.p*,ml.inf*→ GPU variantml.c*,ml.m*,ml.t*→ CPU variant
Mixing them fails: CPU image on a GPU instance wastes hardware, GPU image on a CPU instance fails to start.
Note on the TEI account ID: the catalog page shows 683313688378 as the example account, but TEI is published from a different account namespace than the main AWS DLCs and the per-region account IDs vary. If 683313688378.dkr.ecr.<region>.amazonaws.com/tei:... returns an ECR pull error for a region other than us-east-1, check the Region Availability page for the correct account ID for that region.
vLLM AMI requirement
vLLM DLC images with CUDA 13 or higher (current default: cu130) require setting InferenceAmiVersion=al2-ami-sagemaker-inference-gpu-3-1 on the ProductionVariant. This applies equally to huggingface-vllm and huggingface-vllm-omni (layered on the same cu130 base) and to the AWS vllm repo. Without it the container dies on startup with no CloudWatch logs ever created. The failure looks identical to many other things (account-level issues, quota, networking) and routinely sends people down wrong diagnostic paths.
Lookup table:
| Tag contains | InferenceAmiVersion to pass |
|---|---|
cu130 (or higher) | al2-ami-sagemaker-inference-gpu-3-1 |
cu129 or lower | (omit the flag; default AMI works) |
Rule of thumb: if the vLLM tag you picked contains cu130 or later, pass --inference-ami-version al2-ami-sagemaker-inference-gpu-3-1 to deploy.py. If a future CUDA version (cu140+) needs a different AMI, add a row to the table when AWS publishes the new image.
This is a vLLM-specific concern. TEI and HF Inference Toolkit images don't need an AMI override.
Configuring the vLLM DLCs (HuggingFace vLLM and AWS vLLM)
Both images share the same contract: configuration as environment variables on the SageMaker model definition, SM_VLLM_* mapped to vLLM CLI flags. The huggingface-vllm entrypoint additionally auto-detects the model when SM_VLLM_MODEL is unset — from /opt/ml/model if artifacts are mounted, else from HF_MODEL_ID — but setting SM_VLLM_MODEL explicitly works on both and is what our examples use.
Required for every HuggingFace LLM deployment
| Env var | Purpose | Notes |
|---|---|---|
SM_VLLM_MODEL | HF model ID (e.g. Qwen/Qwen3-0.6B) or /opt/ml/model if loading from S3 | — |
SM_VLLM_HOST | Must be 0.0.0.0 | Otherwise vLLM binds localhost only, ping fails, container dies before logs. Top cause of mystery failures with this image. |
SM_VLLM_TRUST_REMOTE_CODE | true for Qwen and several recent architectures | Set unconditionally — downside negligible, upside is the model loads. |
HUGGING_FACE_HUB_TOKEN | HF token | Required for gated models. |
Tuning (optional)
| Env var | Purpose |
|---|---|
SM_VLLM_MAX_MODEL_LEN | Max sequence length — set this; defaults can be wrong for fine-tunes |
SM_VLLM_GPU_MEMORY_UTILIZATION | Float 0.0–1.0, ~0.9 reasonable |
SM_VLLM_TENSOR_PARALLEL_SIZE | GPU count for multi-GPU instances |
SM_VLLM_DTYPE | auto, bfloat16, float16 |
Any vLLM CLI flag works — uppercase, replace dashes with underscores, prepend SM_VLLM_.
Configuring TEI
Simpler env contract than vLLM:
| Env var | Purpose | Required |
|---|---|---|
HF_MODEL_ID | HF model ID (e.g. BAAI/bge-large-en-v1.5) or /opt/ml/model | Yes |
HF_TOKEN | HF auth token | Only for gated models |
MAX_BATCH_TOKENS | Max tokens per batch (default 16384) | No |
MAX_CLIENT_BATCH_SIZE | Max requests per client batch (default 32) | No |
No host-binding to configure, no trust-remote-code flag. The architectures TEI supports (BERT, CamemBERT, RoBERTa, XLM-RoBERTa, NomicBert, JinaBert, JinaCodeBert, Mistral, Qwen2/3, Gemma2/3, ModernBert) are baked into the image.
CUDA / instance compatibility
Critical and easy to get wrong:
| CUDA in image tag | Default AMI | With al2-ami-sagemaker-inference-gpu-3-1 |
|---|---|---|
| cu124 / cu128 | g5, g6, p5 all work | (not needed) |
| cu129 | g6, p5; g5 fails (driver mismatch → CannotStartContainerError) | expected to fix g5 (unverified) |
| cu130+ | fails everywhere — AMI flag is mandatory | g5, g6, p5 all work (cu130-on-g5 verified June 2026) |
The driver comes from the host AMI, not the instance family — so passing the gpu-3-1 AMI (which vLLM cu130 images require anyway) also makes ml.g5.* viable for cu129+ images.
VPC / NAT gateway problem
SageMaker endpoints inside a VPC without a NAT gateway can't pull from public.ecr.aws. The deployment fails with an image-pull error that doesn't mention "VPC" or "egress".
For images on AWS's regional ECR (everything in the catalog): SageMaker reaches them through built-in routing, no NAT needed. Use the regional URI pattern (<account>.dkr.ecr.<region>.amazonaws.com/...), not the public.ecr.aws/... pattern.
For images requiring public.ecr.aws access (less common): mirror to a private ECR repo in your account with scripts/mirror_image.py (cross-platform; needs Docker + the aws CLI). Run it from the shell where the AWS CLI works.
# macOS / Linux
PRIVATE_URI=$(python3 scripts/mirror_image.py \
public.ecr.aws/deep-learning-containers/vllm:<tag> \
vllm-mirror)
# Windows (PowerShell) — capture stdout into a variable
$PRIVATE_URI = python scripts\mirror_image.py `
public.ecr.aws/deep-learning-containers/vllm:<tag> vllm-mirror
When the catalog page won't render, is stale, or is wrong
The page won't render / fetch returns junk: the catalog page is JavaScript-heavy and some fetch tools get an empty shell. Fallbacks, in order:
- The catalog's source data on GitHub — the page is generated from one YAML file per version, listing exact tags, CUDA, and Python versions. List a family's files, then fetch the newest:<!-- -->
<!-- -->Directory names match ECR repos (curl -s https://api.github.com/repos/aws/deep-learning-containers/contents/docs/src/data/huggingface-vllm curl -s https://raw.githubusercontent.com/aws/deep-learning-containers/main/docs/src/data/huggingface-vllm/0.21.0-gpu-sagemaker.ymlhuggingface-vllm,huggingface-vllm-omni,huggingface-tei,vllm,djl-inference, ...). - Query ECR directly for current tags in the target region (works with credentials that can read the DLC registry; if it returns AccessDenied, use the YAML files):<!-- -->
aws ecr describe-images --registry-id 763104351884 --repository-name huggingface-vllm \ --region <region> --query 'sort_by(imageDetails,&imagePushedAt)[-5:].imageTags' --output json - Release notes on the DLC GitHub repo.
A tag was just released and isn't on the page yet: rare; AWS updates the page on each release. Check the release notes above.
An architecture you need isn't supported by the listed image yet: for TEI specifically, you can mirror the upstream image from GHCR (ghcr.io/huggingface/text-embeddings-inference:<version>] в приватный ECR и передать полученный URI напрямую в deploy.py --image-uri. То же самое mirror_image.py скрипт.
Известные сломанные образы (последняя проверка — июль 2026)
| Образ | Дефект | Использовать вместо |
|---|---|---|
huggingface-pytorch-inference GPU теги — все недавние протестированы (PT 2.3–2.6, cu121/cu124, transformers 4.48–5.5.3) | ImportError: libtorch_cuda.so: undefined symbol: ncclCommResume at import torch. NCCL, входящий в образ, старше той версии, с которой линкуется torch — дефект упаковки внутри контейнера, on g5 и g6, независимо от AMI, модели или кода инференса. Java-фронтенд MMS продолжает отвечать /ping, поэтому эндпоинт может достичь InService, пока Python-воркер циклически падает и ничего не обслуживает. | DJL Inference (включает собственный полный стек CUDA/NCCL) или BYOC. CPU-теги не затронуты. |
Перепроверить, когда AWS опубликует новые huggingface-pytorch-inference GPU-теги — удалить строку, как только будет подтверждён исправленный образ.
Общее правило выбора запасного варианта: когда HF DLC падает с ошибками линковки CUDA/NCCL, переключайтесь на DJL Inference, а не перебирайте соседние теги — этот класс дефектов относится к репозиторию, а не к тегу (для случая выше пробовали три разных тега; все сломаны).
Смежная ловушка HF Hub: старые DLC могут не скачать модель с ошибкой 403 Forbidden из XET CDN от HF (их встроенный huggingface_hub старше поддержки аутентификации XET). Установите HF_HUB_ENABLE_HF_TRANSFER=0 , чтобы принудительно использовать стандартный путь загрузки, или заранее разместите веса в S3.
Время загрузки с Hub при первой загрузке
Загрузка модели с HF Hub происходит внутри контейнера после запуска эндпоинта — ожидайте 5–15+ минут до InService даже для небольших моделей, дольше для моделей в несколько ГБ. Медленная первая загрузка — не сбой; не удаляйте и не передиагностируйте до истечения 30-минутного ожидания скрипта развёртывания.
Для продакшена или повторных развёртываний заранее разместите веса в S3 и передайте --model-s3-uri to deploy.py (тогда модель загружается из /opt/ml/model) — быстрее, не зависит от лимитов/сбоев Hub и не требует HUGGING_FACE_HUB_TOKEN во время выполнения.
Вставить в README
Ссылка на карточку для вашего README — без картинок и счётчиков.
[DarkPlay: hf-cloud-serving-image-selection](https://darkplay.ru/ai/skills/huggingface-skills-hf-cloud-serving-image-selection)
Из того же репозитория
Похожие скиллы и другие разделы каталога
Самые востребованные скиллов раздела по установкам и звёздам.
find-skillsvercel-labs · Помогает находить и устанавливать навыки агентов по запросам вроде «как сделать X»…
grill-memattpocock · Настойчивое интервью для доработки плана или дизайна.
hyperframesheygen-com · Обязательная точка входа для любых задач по видео, анимации и motion-графике в…
hyperframes-cliheygen-com · Цикл разработки HyperFrames CLI: init, add, render, preview, publish и другие команды.
agent-browservercel-labs · CLI для автоматизации браузера для ИИ-агентов: навигация по страницам, заполнение форм…
media-useheygen-com · Agent Media OS: единый навык для медиа в HyperFrames — BGM, SFX, изображения, голос, LUT.
hyperframes-registryheygen-com · Установка и подключение блоков реестра в композиции HyperFrames через add и catalog.
grill-with-docsmattpocock · Настойчивое интервью для доработки плана или дизайна, попутно создающее документацию (ADR…
improve-codebase-architecturemattpocock · Поиск в кодовой базе возможностей для углубления, визуальный HTML-отчёт о них и детальный…
tddmattpocock · Разработка через тестирование (TDD): red-green-refactor и интеграционные тесты.Соседние разделы каталога: возможно, нужный инструмент живёт там.
Code Simplifieraffaan-m · Упрощение и очистка кода без изменения поведения.
Mle Revieweraffaan-m · Ревьюер ML-инженерии: данные, признаки, обучение, оценка, сервинг и мониторинг.
ruflo-agentruvnet · Среды выполнения агентов: локальные агенты в песочнице WASM (rvagent) и Anthropic Claude…
marketing-skillscoreyhaines31 · 47 навыков маркетинга для технических маркетологов и основателей: CRO, копирайтинг…
agentic-bundle-aas-devops-cloudsickn33 · Установите набор редакционных навыков "AAS DevOps & Cloud" для Claude Code.
agentic-bundle-azure-ai-cloudsickn33 · Установите набор редакционных навыков "Azure AI & Cloud" для Claude Code.
agentic-bundle-devops-cloudsickn33 · Установите набор редакционных навыков «DevOps & Cloud» для Claude Code.
adobe-for-creativityanthropics · Инструменты Adobe на основе ИИ для редактирования изображений, автоматизации дизайна и…
amd-skillsanthropics · Проверенные навыки агентов AMD в одном плагине: обработка изображений и звука локальным…
astronomer-data-agentsanthropics · Инженерия данных для Apache Airflow и Astronomer: написание DAG по лучшим практикам…Лучшие ИИ-инструменты для генерации видео
Подборка нейросетей для генерации и монтажа видео. Инструменты, которые превращают текст в готовые ролики, экономят часы на съемках и постпродакшне. Подходит для SMM-специалистов,
VEED.IOVeed
MootionMootion
Sora (OpenAI)OpenAI
viralpulse.appViralpulse
Viral Maker AIViral-makerЛучшие ИИ-инструменты для генерации текста и копирайтинга
Подборка нейросетей для генерации текстов и копирайтинга. Сервисы, которые помогают создавать статьи, посты и рекламные объявления с нуля или по черновику, экономя часы рутинной ра
NeuroscribeNeuroscribe
GoGPTGogpt
НейроТекстерNeuro-texter
ChatGPTOpenAI
Cosmo ScribeCosmoscribe
Memo HelperCopilot33
LibraChatLibrachatЛучшие ИИ-инструменты для генерации изображений
Подборка нейросетей для генерации изображений от фотореализма до концепт-арта. Сервисы, которые экономят часы ручной работы, создавая визуал для блогов, рекламы и дизайна за минуты
MagviMagvi
DALL-E 3OpenAI
SupaLabSupalab
Freestyling.aiFreestyling
ArtGeneration.meArtgeneration
BigjpgBigjpg
Художник от VKVK
Avato AI12ai
Virton AIVirton