Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

ModelBuilder with source_code + DJL LMI: /opt/ml/model becomes read-only, breaking HF Hub model downloads

Offen
#5,698 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
aws, python

Rechercherichtung

Beginne bei ModelBuilder.build() und deploy(), zusammen mit der SourceCode-Paketierung, und reproduziere das Problem mit dem DJL LMI image und der bereitgestellten Modellkonfiguration. Verfolge, wie source_code paketiert wird und wie HF_MODEL_ID und env_vars angewendet werden. Als erledigt gilt die Aufgabe, wenn Downloads des Runtime-Modells an einen beschreibbaren Speicherort schreiben können und eine vom Benutzer bereitgestellte HF_MODEL_ID nicht unerwartet ersetzt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description

When using ModelBuilder (SDK v3) with a pre-built DJL LMI container image and source_code (via SourceCode) to provide custom requirements.txt, the model directory /opt/ml/model/ becomes read-only at runtime. This prevents the DJL container from downloading models from HuggingFace Hub, which tries to write cache files to /opt/ml/model/.

Additionally, ModelBuilder overrides user-provided HF_MODEL_ID environment variable with the value from the model= parameter, making it impossible to point the container to the local model path (/opt/ml/model) when S3 model artifacts are also provided via s3_model_data_url.

How to Reproduce

from sagemaker.serve import ModelBuilder, ModelServer
from sagemaker.serve.builder.schema_builder import SchemaBuilder
from sagemaker.serve.mode.function_pointers import Mode
from sagemaker.serve.model_builder import SourceCode

source_code = SourceCode(
    source_dir="./model_code",
    requirements="requirements.txt",  # e.g. transformers>=4.55.0
)

mb = ModelBuilder(
    model="chromadb/context-1",  # HF Hub model ID
    role_arn=ROLE,
    image_uri="763104351884.dkr.ecr.us-east-1.amazonaws.com/djl-inference:0.36.0-lmi22.0.0-cu129",
    model_server=ModelServer.DJL_SERVING,
    schema_builder=SchemaBuilder(
        {"inputs": "Hello", "parameters": {"max_new_tokens": 64}},
        [{"generated_text": "Hi"}],
    ),
    source_code=source_code,
    env_vars={"OPTION_TENSOR_PARALLEL_DEGREE": "4", ...},
    instance_type="ml.g6e.12xlarge",
    mode=Mode.SAGEMAKER_ENDPOINT,
)

model = mb.build()
endpoint = mb.deploy(endpoint_name="test", wait=True)
# FAILS: OSError: [Errno 30] Read-only file system: /opt/ml/model/models--chromadb--context-1

Observed Behavior

  1. ModelBuilder.build() packages the source_code directory into a model.tar.gz and uploads to S3
  2. At deploy time, SageMaker mounts this tar.gz at /opt/ml/model/ — which becomes read-only
  3. ModelBuilder sets HF_MODEL_ID=chromadb/context-1 (from model=), overriding any user-provided value
  4. DJL LMI container sees HF_MODEL_ID=chromadb/context-1 and tries to download from HF Hub
  5. HF Hub download tries to write cache to /opt/ml/model/models--chromadb--context-1/
  6. Fails with OSError: [Errno 30] Read-only file system

CloudWatch logs confirm:

OSError: [Errno 30] Read-only file system: /opt/ml/model/models--chromadb--context-1

Expected Behavior

Users should be able to use ModelBuilder with:

  • A pre-built container image (e.g. DJL LMI)
  • source_code with a custom requirements.txt to install additional dependencies at container startup
  • A HuggingFace Hub model ID that the container downloads at runtime

The requirements.txt installation should not make /opt/ml/model/ read-only, or the HF Hub cache should be redirected to a writable location (e.g. /tmp).

Workaround Attempted

Setting HF_HOME=/tmp/hf_home and HUGGINGFACE_HUB_CACHE=/tmp/hf_home/hub in env_vars — these appear in the container environment but the DJL container still writes to /opt/ml/model/.

Use Case

This is a common pattern for deploying newer models (e.g. OpenAI GPT-OSS based models like chromadb/context-1) that require a newer transformers version than what is bundled in the DJL LMI container. The source_code with requirements.txt is the natural SDK v3 mechanism for this, but it is incompatible with HF Hub model downloads.

Environment

  • SageMaker Python SDK: 3.6.0
  • Container: djl-inference:0.36.0-lmi22.0.0-cu129
  • Instance: ml.g6e.12xlarge
  • Region: us-east-1
Vorherrschende Sprache
Python
Sterne
2.3k
Forks
1.3k
Ø Merge
3 T. 2 Std.
Gemergte PRs (30 T.)
70

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aws/sagemaker-python-sdk

Alle Issues in aws/sagemaker-python-sdk

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.