ModelBuilder with source_code + DJL LMI: /opt/ml/model becomes read-only, breaking HF Hub model downloads
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- aws, python
調査の方向性
ModelBuilder.build() と deploy()、および SourceCode のパッケージ化から始め、DJL LMI image と提供されたモデル設定で問題を再現します。source_code がどのようにパッケージ化され、HF_MODEL_ID と env_vars がどのように適用されるかを追跡します。ランタイムモデルのダウンロードが書き込み可能な場所に書き込め、ユーザーが指定した HF_MODEL_ID が予期せず置き換えられなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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
ModelBuilder.build()packages thesource_codedirectory into amodel.tar.gzand uploads to S3- At deploy time, SageMaker mounts this tar.gz at
/opt/ml/model/— which becomes read-only ModelBuildersetsHF_MODEL_ID=chromadb/context-1(frommodel=), overriding any user-provided value- DJL LMI container sees
HF_MODEL_ID=chromadb/context-1and tries to download from HF Hub - HF Hub download tries to write cache to
/opt/ml/model/models--chromadb--context-1/ - 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_codewith a customrequirements.txtto 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
- 主要言語
- Python
- スター
- 2.3k
- フォーク
- 1.3k
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 82
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws/sagemaker-python-sdk のほかの issue
-
Cannot use spark_event_logs_s3_uri in PySparkProcessor job対応中かも @rsareddy0329 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/sagemaker-python-sdk#6253 ·
メンテナーはふだん 2 日以内に返信
-
[Bug] V3 Hyperparameter Tuning Pipeline page labelled "Download Data" in navigation due to missing title cell対応中かも @admivsn が 35 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 93/100
aws/sagemaker-python-sdk#6232 ·
メンテナーはふだん 2 日以内に返信
-
[Bug] ModelTrainer with no input channels emits InputDataConfig: [], which CreatePipeline rejects (min=1) — v2 omitted the key対応中かも @sagemaker-bot が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws/sagemaker-python-sdk#6156 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
sagemaker-train should depend on mlflow-skinny, following sagemaker-mlflow 0.5.0対応中かも @mohamedzeidan2021 が 8 日前に担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 72/100
aws/sagemaker-python-sdk#6152 ·
メンテナーはふだん 2 日以内に返信
-
ModelTrainer generates sm_train.sh with CRLF line endings on Windows causing training job failure対応中かも @MohammedAlkindi が 26 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
aws/sagemaker-python-sdk#5904 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
aws/sagemaker-python-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
area:docs
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RailtownAI/railtracks#1633 ·
メンテナーはふだん 2 日以内に返信
-
review-panel severity:low
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
kristovatlas/coin-accounting#152 ·
メンテナーはふだん 1 日以内に返信
-
documentation :blue_book:
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
PennyLaneAI/pennylane#10280 ·
メンテナーはふだん 2 日以内に返信
-
`pipx reinstall` prints a Python traceback when the reinstall fails対応中かも @ParamTanna が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信