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

Tensorflow: fail to download saved model

Open jaelynwu opened this issue 8 years ago • 5 comments

I tried to save checkpoints and summaries every N steps by specify them in the run_config in tf.estimator.DNNClassifier Everything went fine but an error occurred in the end: tf_container.serve - Failed to download saved model. File does not exist in s3://xxxxx Output folder and checkpoint folder are specified but the checkpoints still write to the tmp folder. Also, there are no output folder and checkpoints folder generated in the path I specified.

jaelynwu avatar Feb 16 '18 17:02 jaelynwu

Hi, and thanks for trying SageMaker.

Could you provide details how did you specified the output path and checkpoint? By default 'output_path' defaults to s3://sagemaker-region-account and checkpoint_path is relative to that - appends training_job_name/checkpoints to that but you can always overwrite. Is that what you did? If so, could you try to run with defaults and see if this passes?

lukmis avatar Feb 16 '18 18:02 lukmis

I used the TensorFlow class from sagemaker to train and evaluate: from sagemaker.tensorflow import TensorFlow tf_estimator = TensorFlow(entry_point='dnn_classifier.py', role=role, training_steps=10000, output_path = 's3://xxxx/model', checkpoint_path = 's3://xxxx/checkpoints', train_instance_count=1, train_instance_type='ml.p2.xlarge') tf_estimator.fit('s3://xxx')

in the entry dnn_classifier.py the estimator_fu is as below: def estimator_fn(run_config, params): feature_columns = [tf.feature_column.numeric_column(INPUT_TENSOR_NAME, shape=[NUM_FEATURES])] return tf.estimator.DNNClassifier(feature_columns=feature_columns, hidden_units=[256, 200], n_classes=NUM_CLASSES,
dropout=0.2, config = run_config.replace(save_checkpoints_steps=100, save_summary_steps=100, keep_checkpoint_max = 20) )

jaelynwu avatar Feb 19 '18 08:02 jaelynwu

Thanks for the details.

Btw, you may set the config values using hyperparameters too, this way no need to hardcode it in the script, please see: https://github.com/aws/sagemaker-python-sdk#optional-hyperparameters

I think the reason you do not see the output folder is because the job failed before writing anything there.

I've tried to reproduce your case and point to different output_path and checkpoint_path but in my case the checkpoint location was created and used. Output was also created upon success.

Could you check the logs and post what you see for "_model_dir" when the config is printed, e.g.: INFO:tensorflow:Using config: {'_model_dir': u's3://xxx/another_test/checkpoints', '_save_checkpoints_secs': 300, '_num_ps_replicas': 0, '_keep_checkpoint_max': 5,

and if there are any other warnings? Which region did you run the job in?

lukmis avatar Feb 20 '18 01:02 lukmis

Thanks a lot for your help! You are right, it's because of some other problem in the job so that the job didn't succeed completely. I can see the output and checkpoint folder now :) The log looked all right though, except that there is the warning about "Monitors are deprecated". Thanks for the advice about hyperparameters as well!

jaelynwu avatar Feb 21 '18 10:02 jaelynwu

Hi, please let us know if the problem still persists. We are going to close this issue in 7 days if we don't hear back from you.

nadiaya avatar Mar 01 '18 19:03 nadiaya