user10818652
user10818652

Reputation:

What is the SageMaker TensorFlow SavedModel export format?

I'm new to AWS SageMaker TensorFlow 1.11.0 script mode. Been looking around the documentation for a while and can't seem to find the folder structure to export the model in after training. All I know is that I'm suppose to export to the directory specified in the env variable "SM_MODEL_DIR" and that the format is SavedModel.

I've used tf.saved_model.simple_save to export in the following folder structure:

- model.tar.gz
-- saved_model.pb
-- variables
--- variables.index
--- variables.data-00000-of-00001

But upon deploying, I get the error:

Traceback (most recent call last):
File "/sagemaker/serve.py", line 189, in <module>
ServiceManager().start()
File "/sagemaker/serve.py", line 163, in start
self._create_tfs_config()
File "/sagemaker/serve.py", line 53, in _create_tfs_config
raise ValueError('no SavedModel bundles found!')

any help would be nice. Thx

Upvotes: 3

Views: 1826

Answers (1)

jesterhazy
jesterhazy

Reputation: 238

You are seeing this error because TensorFlow Serving (which SageMaker uses to host your model) requires the SavedModel to be nested in a version subdirectory.

Add a version directory your model archive to this structure to make it work. Example:

- model.tar.gz
-- 1
--- saved_model.pb
--- variables
---- variables.index
---- variables.data-00000-of-00001

See the Load and serve a SavedModel in TensorFlow serving section of the TensorFlow Save and Restore Guide for more info.

Upvotes: 4

Related Questions