Skip to content

Remote Training Job created with decorator not installing pip dependencies #4484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asarasua opened this issue Mar 7, 2024 · 2 comments · Fixed by #4487
Closed

Remote Training Job created with decorator not installing pip dependencies #4484

asarasua opened this issue Mar 7, 2024 · 2 comments · Fixed by #4487
Labels
component: pipelines Relates to the SageMaker Pipeline Platform remote-function Relates to Pathways feature type: bug

Comments

@asarasua
Copy link

asarasua commented Mar 7, 2024

Describe the bug
After upgrading to version 2.212.0, pip dependencies passed as a requirements.txt file in @remote decorator are not installed. Same code works fine in versions up to 2.209.x, fails with versions from 2.210.x.

To reproduce
Just tried with the toy example from the documentation:

import boto3
import sagemaker
from sagemaker.remote_function import remote

sm_session = sagemaker.Session(boto_session=boto3.session.Session(region_name="us-east-1"))
settings = dict(
    sagemaker_session=sm_session,
    role=<The IAM role name>,
    instance_type="ml.m5.xlarge",
    dependencies='./requirements.txt'
)

@remote(**settings)
def divide(x, y):
    return x / y


if __name__ == "__main__":
    print(divide(2, 3.0))

And got this in the Training Job, showing no pip install logging before (sagemaker is listed in requirements.txt):

  File "/opt/ml/input/data/sagemaker_remote_function_bootstrap/bootstrap_runtime_environment.py", line 24, in <module>
    from runtime_environment_manager import (
  File "/opt/ml/input/data/sagemaker_remote_function_bootstrap/runtime_environment_manager.py", line 27, in <module>
    import sagemaker
ModuleNotFoundError: No module named 'sagemaker'

Using sagemaker sdk versions previous to 2.210.x, the job prints pip install logging and then runs the operation without problems.

We observed equivalent problems in our code for remote functions that were working fine before upgrading.

Expected behavior
The training job should start by installing the dependencies defined in requirements.txt

System information

  • SageMaker Python SDK version: tried with 2.210.0, 2.211.0, 2.212.0
  • Python version: 3.8.18
  • CPU or GPU: CPU
@navaj0 navaj0 added the component: pipelines Relates to the SageMaker Pipeline Platform label Mar 7, 2024
@knikure knikure added the remote-function Relates to Pathways feature label Mar 7, 2024
@nmadan
Copy link
Member

nmadan commented Mar 8, 2024

Hi @asarasua, thanks for opening an issue for this. We are actively working on a fix.

@arun-akur8
Copy link

arun-akur8 commented May 22, 2024

Hello!

It seems I still get the same error when using remote decorator in VSCode in Code Editor Space in AWS Sagemaker Studio. Would it be the same issue?

Error is :

/miniconda3/bin/python: Error while finding module specification for 'sagemaker.remote_function.invoke_function' (ModuleNotFoundError: No module named 'sagemaker')

Minimal code example:

from sagemaker.remote_function import remote
import sagemaker
import boto3
boto_session = boto3.Session()
sm_session = sagemaker.Session(boto_session,default_bucket="default_bucket")
image_uri = sagemaker.image_uris.retrieve(sagemaker.image_uris.SKLEARN_FRAMEWORK,version="1.2-1",region=region)
settings = dict(
         sagemaker_session=sm_session,
         role=sagemaker.get_execution_role(),
         instance_type="ml.m5.large", image_uri=image_uri)

sagemaker version: 2.200.0, 2.221.0
Python version: 3.8
Boto version: 1.34.109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pipelines Relates to the SageMaker Pipeline Platform remote-function Relates to Pathways feature type: bug
Projects
None yet
5 participants