2

I'm attempting to deploy a local tensorflow model to a sagemaker endpoint. I want to include custom inference code to transform the input data. Given the model is trained and already located in an S3 bucket, I can run the following, which correctly deploys the model to an endpoint:

tensorflow_model = Model(
        model_data=saved_model,
        entry_point='src/development/document_matcher/inference.py',
        source_dir ='./src/development/document_matcher',      
        role=role, 
        framework_version=tf_framework_version
        )

The inference file is working correctly; however, I also need the vocabulary for the model to transform the incoming data correctly. This is what I'm trying to upload with source_dir.

My Directory structure is as follows:

- src
 - development
  -document_matcher
   - inference.py
   - total_vocab.pkl

I need to have total_vocab.pkl accessible to my inference script when it runs. However, inference.py is unable to find it. Am I misunderstanding how sagemaker works?

2 Answers 2

0

According to the SageMaker TF container your total_vocab.pkl should be in /opt/ml/model/code

If it is not, seeing that your inference.py file is running I suggest adding some print statements to list directories.

Sign up to request clarification or add additional context in comments.

Comments

0

As stated in the documentation, 'If source_dir is specified, then entry_point must point to a file located at the root of source_dir'. Therefore, since your Model object already unzips the whole document_matcher in the same location as your model, you can simply put entry_point = inference.py. And your total_vocab.pkl object will be available in your inference.py code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.