amazon-sagemaker-examples icon indicating copy to clipboard operation
amazon-sagemaker-examples copied to clipboard

step_functions_mlworkflow_scikit_learn_data_processing_and_model_evaluation.ipynb cannot import name 'get_image_uri'

Open aaronmarkham opened this issue 6 years ago • 8 comments

https://github.com/awslabs/amazon-sagemaker-examples/blob/master/step-functions-data-science-sdk/step_functions_mlworkflow_processing/step_functions_mlworkflow_scikit_learn_data_processing_and_model_evaluation.ipynb

ImportError: cannot import name 'get_image_uri'

aaronmarkham avatar Aug 04 '20 21:08 aaronmarkham

@dhawalkp

aaronmarkham avatar Aug 04 '20 21:08 aaronmarkham

It's possible that you're using SM SDK 2, where as the tutorial seems to have been written for SM 1.x. Updating your code: https://sagemaker.readthedocs.io/en/stable/v2.html#image-uri-functions-e-g-get-image-uri or downgrading your SM SDK version should prevent the issue. The author should add a stronger condition for the SDK version when importing.

shashankprasanna avatar Aug 04 '20 23:08 shashankprasanna

Hi @aaronmarkham, @shashankprasanna is correct! This tutorial is written for SM 1.x SDK. For time being, please change the code in the first code cell to below to make it more restrictive -

!{sys.executable} -m pip install -qU awscli boto3 "sagemaker>=1.71.0,<2.0.0"

I will check-in the code meanwhile with this change

dhawalkp avatar Aug 05 '20 00:08 dhawalkp

Hi, I changed the code into !pip install -qU awscli boto3 sagemaker>=1.71.0,<2.0.0,

but it still says ImportError: cannot import name 'get_image_uri'

I'm running the Object Detection using Managed Spot Training.

捕获

ElaineYao avatar Sep 23 '20 13:09 ElaineYao

Try getting rid of the -qU so you can see what is happening. Also, try restarting your kernel after the installation/rollback is successful. I have some rollback code over here: #1570

aaronmarkham avatar Sep 25 '20 16:09 aaronmarkham

@ElaineYao I had the same issue and just stuck with pip install 'sagemaker<=1.71.0' and it's now moved past the error you're showing. HTH.

leafmulch avatar Oct 03 '20 11:10 leafmulch

Hi @ElaineYao: I encountered the exact error this week in my SageMaker Studio a different notebook and was able to fix it by executing the following to downgrade my SageMaker SDK version to match the legacy code: import sys !{sys.executable} -m pip install -qU awscli boto3 "sagemaker>=1.71.0,<2.0.0"

mikwin1 avatar Oct 03 '20 14:10 mikwin1

Closing as the notebook was pinned to a SDKv1 so it should work. There is however another issue out to upgrade these notebooks: https://github.com/aws/amazon-sagemaker-examples/issues/1568

seanpmorgan avatar Feb 16 '21 23:02 seanpmorgan