sagemaker-python-sdk icon indicating copy to clipboard operation
sagemaker-python-sdk copied to clipboard

support requirements.txt in TF serving

Open chinazm opened this issue 8 years ago • 5 comments

Do you support customized packages (installing dependences) in serving mode?

chinazm avatar Mar 08 '18 01:03 chinazm

Hi @chinazm ,

Yes, with the requirements_file parameter:

https://github.com/aws/sagemaker-python-sdk/blob/6b809eba605119ff274b39b3c8df3dd1163e784a/src/sagemaker/tensorflow/estimator.py#L123-L125

I just updated https://github.com/aws/sagemaker-python-sdk/issues/84. I suspect that we're not handling your use case correctly in the image, though. We'll investigate that further.

Thanks!

andremoeller avatar Mar 08 '18 01:03 andremoeller

Sorry I may not make the question clear. When do the training, you can specify the requirements_file, in Tensorflow. However, when you deploy the model for serving, estimator.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge'), I don't think there is a requirements.txt to be deployed in the endpoint container...

Thank you!

chinazm avatar Mar 08 '18 04:03 chinazm

Hi @chinazm,

The requirements.txt file should work in this hosting case, but it seems from the other issue that it isn't working for your case. We're looking into this now. Thanks!

andremoeller avatar Mar 08 '18 23:03 andremoeller

i was able to get around this by adding this code before the relavent imports:

try:
    from pip import main as pipmain
except:
    from pip._internal import main as pipmain
requirements=os.path.dirname(__file__)
pipmain(['install', "--upgrade", "pip"])
pipmain(['install', "-r","requirements"])

change requirements to point to your requirements file

JohnCalhoun avatar Jun 30 '18 23:06 JohnCalhoun

@JohnCalhoun Your solution doesn't work for me. It throws an error saying TypeError: super(type, obj): obj must be an instance or subtype of type. Do you happen to know how to trouble-shoot this?

K-AlfredIwasaki avatar Jul 12 '18 22:07 K-AlfredIwasaki