You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deploying a HuggingFace model with model data on disk, sagemaker SDK still tries to access the AWS API to determine the Sagemaker default bucket. I don't currently have access to my AWS credentials, so this is failing with access denied errors. I would like to be able to run locally without needing S3 access, and this is blocking me from doing so.
To reproduce
In an environment without AWS Access (no credentials setup).
from sagemaker.huggingface import HuggingFaceModel
from sagemaker import Session, get_execution_role
from sagemaker.local import LocalSession
# sagemaker_session = LocalSession()
# sagemaker_session.config = {'local': {'local_code': True}}
huggingface_model = HuggingFaceModel(
model_data="file:///path/to/model.tar.gz", # path to your trained SageMaker model
role='SageMakerRole', # IAM role with permissions to create an endpoint
transformers_version="4.26", # Transformers version used
pytorch_version="1.13", # PyTorch version used
py_version='py39',
)
huggingface_model.deploy(
initial_instance_count=1,
instance_type='local'
)
Maybe I still need access to AWS via the HF inference toolkit pulling the correct ECR image? However, that doesn't seem to be where it's failing.
Expected behavior
Local mode to deploy an endpoint into a Docker container.
System information
A description of your system. Please provide:
It looks like regardless of the local code setting in ~/.sagemaker/config.yaml, the SDK will still try to access the S3 API to determine the default bucket name for sagemaker.
def_upload_code(self, key_prefix: str, repack: bool=False) ->None:
"""Uploads code to S3 to be used with script mode with SageMaker inference. Args: key_prefix (str): The S3 key associated with the ``code_location`` parameter of the ``Model`` class. repack (bool): Optional. Set to ``True`` to indicate that the source code and model artifact should be repackaged into a new S3 object. (default: False). """local_code=utils.get_config_value("local.local_code", self.sagemaker_session.config)
bucket, key_prefix=s3.determine_bucket_and_prefix(
bucket=self.bucket,
key_prefix=key_prefix,
sagemaker_session=self.sagemaker_session,
)
if (self.sagemaker_session.local_modeandlocal_code) orself.entry_pointisNone:
self.uploaded_code=Noneelifnotrepack:
self.uploaded_code=fw_utils.tar_and_upload_dir(
session=self.sagemaker_session.boto_session,
bucket=bucket,
s3_key_prefix=key_prefix,
script=self.entry_point,
directory=self.source_dir,
dependencies=self.dependencies,
kms_key=self.model_kms_key,
settings=self.sagemaker_session.settings,
)
# ...
Within determine_bucket_and_prefix, sagemaker_session.default_bucket() is called. In my environment, this still fails even with a LocalSession object.
jaketothepast
changed the title
Sagemaker Local Mode with Local Code setting still requires S3 access
Sagemaker Local Mode with Local Code setting and HuggingFaceModel still requires S3 access
May 1, 2024
Describe the bug
When deploying a HuggingFace model with model data on disk, sagemaker SDK still tries to access the AWS API to determine the Sagemaker default bucket. I don't currently have access to my AWS credentials, so this is failing with access denied errors. I would like to be able to run locally without needing S3 access, and this is blocking me from doing so.
To reproduce
In an environment without AWS Access (no credentials setup).
Maybe I still need access to AWS via the HF inference toolkit pulling the correct ECR image? However, that doesn't seem to be where it's failing.
Expected behavior
Local mode to deploy an endpoint into a Docker container.
System information
A description of your system. Please provide:
[tool.poetry.dependencies]
python = "^3.12"
sagemaker = {extras = ["local"], version = "^2.217.0"}
jupyterlab = "^4.1.8"
setuptools = "^69.5.1"
Additional context
It looks like regardless of the local code setting in
~/.sagemaker/config.yaml
, the SDK will still try to access the S3 API to determine the default bucket name for sagemaker.From
sagemaker-python-sdk/src/sagemaker/model.py
Line 694 in b17d332
Within
determine_bucket_and_prefix
,sagemaker_session.default_bucket()
is called. In my environment, this still fails even with aLocalSession
object.Why is a LocalSession still trying to access S3?
The text was updated successfully, but these errors were encountered: