Skip to content

AttributeError: 'Session' object has no attribute 'settings' #5198

Closed
@vektaBastien

Description

@vektaBastien

Describe the bug
Sagemaker tries to access the settings attribute of the sagemaker.modules.Session()wich does not exists.

To reproduce

import sagemaker
import boto3
from sagemaker.modules import Session
from sagemaker.pytorch import PyTorch

boto_session = boto3.Session(profile_name="vekta-production")
sagemaker_session = Session(boto_session=boto_session)

estimator = PyTorch(
    entry_point="train.py",
    source_dir=".",
    role="arn:aws:iam::261877606600:role/SageMakerRoleu",
    instance_count=1,
    instance_type="ml.t3.medium",
    framework_version="1.12.0",
    py_version="py38",
    sagemaker_session=sagemaker_session,
)
estimator.fit()

Screenshots or logs
logs:

│ /home/bastien/python_env/base/lib/python3.12/site-packages/sagemaker/estimator.py:967 in         │
│ _prepare_for_training                                                                            │
│                                                                                                  │
│    964 │   │   │   │   script = self.uploaded_code.script_name                                   │
│    965 │   │   │   │   self.code_uri = self.uploaded_code.s3_prefix                              │
│    966 │   │   │   else:                                                                         │
│ ❱  967 │   │   │   │   self.uploaded_code = self._stage_user_code_in_s3()                        │
│    968 │   │   │   │   code_dir = self.uploaded_code.s3_prefix                                   │
│    969 │   │   │   │   script = self.uploaded_code.script_name                                   │
│    970                                                                                           │
│                                                                                                  │
│ /home/bastien/python_env/base/lib/python3.12/site-packages/sagemaker/estimator.py:1058 in        │
│ _stage_user_code_in_s3                                                                           │
│                                                                                                  │
│   1055 │   │   │   dependencies=self.dependencies,                                               │
│   1056 │   │   │   kms_key=kms_key,                                                              │
│   1057 │   │   │   s3_resource=self.sagemaker_session.s3_resource,                               │
│ ❱ 1058 │   │   │   settings=self.sagemaker_session.settings,                                     │
│   1059 │   │   )                                                                                 │
│   1060 │                                                                                         │
│   1061 │   def _assign_s3_prefix(self, key_prefix=""):                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Session' object has no attribute 'settings'

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 2.245.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): Pytorch
  • Framework version: 1.12.0-cpu
  • Python version:3.12.3
  • CPU or GPU:CPU
  • Custom Docker image (Y/N):N

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: trainingRelates to the SageMaker Training Platform

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions