Skip to content

TensorFlowModel is not available in SageMaker Pipelines #2791

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
matsuyusu opened this issue Dec 8, 2021 · 5 comments
Closed

TensorFlowModel is not available in SageMaker Pipelines #2791

matsuyusu opened this issue Dec 8, 2021 · 5 comments
Assignees
Labels
component: pipelines Relates to the SageMaker Pipeline Platform type: bug

Comments

@matsuyusu
Copy link

Describe the bug
A clear and concise description of what the bug is.

For TensorFlowModel in sagemaker.tensorflow.model, if model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts, then we get an error. if model_data=s3/path/model.tar.gz, then the execution will be successful.

To reproduce
A clear, step-by-step set of instructions to reproduce the bug.

To use SageMaker Pipelines, we write pipeline.py.
In pipeline.py, we must create a model to define a batch inference as follow.

from sagemaker.tensorflow.model import TensorFlowModel
model = TensorFlowModel(
    entry_point=os.path.join(BASE_DIR, 'inference.py'),
    model_data=step_train.properties.ModelArtifacts.S3ModelArtifacts,
    source_dir=BASE_DIR,
    role=role,
    name='XXX',
    framework_version=TF_VERSION,
    sagemaker_session=sagemaker_session)

Expected behavior
A clear and concise description of what you expected to happen.

Transform using a model created in TrainingStep.

Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.

We get the following exception:
Exception: 'Properties' object has no attribute 'lower'

System information
A description of your system. Please provide:

  • SageMaker Python SDK version:2.70.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): TensorFlow
  • Framework version:1.15.2
  • Python version:3.7
  • CPU or GPU:CPU
  • Custom Docker image (Y/N):N

Additional context
Add any other context about the problem here.

@asmaier
Copy link

asmaier commented Jan 3, 2022

Is there a workaround for this issue? Hardcoding the model_data path doesn't help much, because the path chances every time the pipeline is running.

@matsuyusu
Copy link
Author

We can use FrameworkModel or Model, which is bases of TensorFlowModel, as an alternative. However, it is not possible to embed inference.py and requirements.txt into model.tar.gz, so we need to deal with them separately.

@asmaier
Copy link

asmaier commented Jan 5, 2022

In my case even hardcoding the model_data path like

model_data = "s3://test/model.tar.gz"

does not work. I get the same error: Exception: 'Properties' object has no attribute 'lower'. I tried to debug the issue and believe that in

the model_data string gets overwritten by some Properties leading to the exception. I tried to comment out that line, but then I got another confusing error botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found .

So maybe there is more than one issue to be fixed here. But I don't understand the code good enough to really pinpoint the issue.

@EthanShouhanCheng EthanShouhanCheng added the component: pipelines Relates to the SageMaker Pipeline Platform label Jan 6, 2022
@matsuyusu
Copy link
Author

image
In my environment, the above code looks like the attached file, but it works.
My code is as follows.

    model = TensorFlowModel(
        entry_point=os.path.join(BASE_DIR, 'inference.py'),
        model_data="s3:/test/model.tar.gz",
        source_dir=BASE_DIR,
        role=role,
        name='test',
        framework_version=TF_VERSION,
        sagemaker_session=sagemaker_session)

@qidewenwhen
Copy link
Member

@matsuyusu, sorry for the inconvenience.
The fix has been finally released in SM PySDK v2.85.0. Please check if it works for you.

Closing this issue. Feel free to reopen if you have further questions.

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 type: bug
Projects
None yet
Development

No branches or pull requests

4 participants