Skip to content

Sagmaker Batch Transform has no internet connectivity sometimes.

0

Getting the following error message in cloudfront while trying to fetch model from huggingface.

model error - We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like training-job-1758016709 is not the path to a directory containing a file named config.json. 2025-09-16T11:24:33,851 [INFO ] W-9000-model-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle - Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

2 Answers
6

Try fix at the following:

  1. Enable Internet Access in VPC • Attach a NAT Gateway to your VPC. • Ensure your SageMaker subnet routes outbound traffic through the NAT. • Update your security groups and route tables to allow outbound HTTPS (port 443).
  2. Use Pre-downloaded Models • Download the Hugging Face model files locally:
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("bert-base-uncased", cache_dir="/opt/ml/model")

• Package them with your inference code and upload to S3. • Point your Batch Transform job to the S3 model location. 3. Use Offline Mode • Set environment variable:

TRANSFORMERS_OFFLINE=1

• This forces the Transformers library to use only local files and skip internet access. 4. Use Hugging Face DLC (Deep Learning Container) • If you're using Hugging Face DLC in SageMaker, make sure the container has the model pre-baked or cached.

EXPERT

answered a year ago

0

Hey,

Hope you're keeping well.

Batch Transform jobs in SageMaker run inside your specified VPC settings, so if your subnets don’t have a NAT Gateway or internet-facing route, the container won’t be able to reach Hugging Face. Check the subnet’s route table to ensure 0.0.0.0/0 points to a NAT Gateway, and verify that the security group allows outbound HTTPS traffic. If internet access isn’t possible, download the model files ahead of time, store them in S3, and reference them locally in your job, or set TRANSFORMERS_OFFLINE=1 so the container uses cached files only.

Thanks and regards,
Taz

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.