Closed
Description
Describe the bug
Model Trainer does not recognize my sagemaker session and returns an error.
To reproduce
import sagemaker
from sagemaker.modules.train import ModelTrainer
from sagemaker.modules.configs import SourceCode, Compute
sagemaker_session = sagemaker.session.Session()
print('session:', sagemaker_session)
source_code = SourceCode(
source_dir=".",
requirements="requirements.txt",
entry_script="train.py",
)
compute = Compute(instance_type="ml.t3.medium")
model_trainer = ModelTrainer(
training_image="pytorch/pytorch:1.12.0-cpu",
source_code=source_code,
base_job_name="script-mode",
compute=compute,
role="arn:aws:iam::261877606600:role/SageMakerRoleu",
sagemaker_session=sagemaker_session,
)
Expected behavior
No error
Screenshots or logs
ValidationError: 1 validation error for ModelTrainer
sagemaker_session
Input should be an instance of Session [type=is_instance_of, input_value=<sagemaker.session.Sessio...bject at 0x7a7f0687cd10>, input_type=Session]
For further information visit https://errors.pydantic.dev/2.11/v/is_instance_of
[Process exited 1]
System information
A description of your system. Please provide:
- SageMaker Python SDK: 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
The session output gives:
session: <sagemaker.session.Session object at 0x73f8fdd78da0>
I do not get why the error tells me that it should be an instance of Session, as it is an instance of Session.
Also, I get warnings:
sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/xdg-i3/sagemaker/config.yaml
sagemaker.config INFO - Not applying SDK defaults from location: /home/bastien/.config/sagemaker/config.yaml
I am logging using sso login.