aws / aws/amazon-sagemaker-examples

pytorch_torchvision_neo_studio.ipynb: ImportError: cannot import name 'NEO_IMAGE_ACCOUNT' from 'sagemaker.model'

Open
#1,778 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
11k
Forks
7k
Avg merge
8h 29m
Merged PRs (30d)
8

Description

I tested the NB using SM Studio:

Src: https://github.com/aws/amazon-sagemaker-examples/blob/master/aws_sagemaker_studio/sagemaker_neo_compilation_jobs/pytorch_torchvision/pytorch_torchvision_neo_studio.ipynb

## Issue

```
from sagemaker.model import NEO_IMAGE_ACCOUNT
from sagemaker.fw_utils import create_image_uri

model_name = name_from_base('TorchVision-ResNet18-Neo')

image_uri = create_image_uri(region, 'neo-' + framework.lower(), target_device.replace('_', '.'),
framework_version, py_version='py3', account=NEO_IMAGE_ACCOUNT[region])

response = sm_client.create_model(
ModelName=model_name,
PrimaryContainer={
'Image': image_uri,
'ModelDataUrl': compiled_model_path,
'Environment': { 'SAGEMAKER_SUBMIT_DIRECTORY': source_path }
},
ExecutionRoleArn=role
)
print(response)

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in
----> 1 from sagemaker.model import NEO_IMAGE_ACCOUNT
2 from sagemaker.fw_utils import create_image_uri
3
4 model_name = name_from_base('TorchVision-ResNet18-Neo')
5

ImportError: cannot import name 'NEO_IMAGE_ACCOUNT' from 'sagemaker.model' (/opt/conda/lib/python3.7/site-packages/sagemaker/model.py)
```

## How to Resolve

Seems like following are depreciated:
Quote: https://sagemaker.readthedocs.io/en/stable/v2.html
> The following functions have been deprecated in favor of sagemaker.image_uris.retrieve():
>
> sagemaker.amazon_estimator.get_image_uri()
>
> sagemaker.fw_utils.create_image_uri()
>

But couldn't find info about the NEO_IMAGE_ACCOUNT.

Contributor guide

Open the contributing guide

Research direction

Open aws_sagemaker_studio/sagemaker_neo_compilation_jobs/pytorch_torchvision/pytorch_torchvision_neo_studio.ipynb and inspect the cell importing NEO_IMAGE_ACCOUNT and create_image_uri. Compare those imports with the referenced SageMaker v2 guidance for sagemaker.image_uris.retrieve(), then run the notebook in SageMaker Studio. Done means the cell runs without ImportError and the model creation request succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, jupyter-notebook, python, pytorch
Domain
cloud, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.