title: SageMaker Estimator use_spot_instances causes Invalid MaxWaitTimeInSeconds
body: <p><a href="https://aws.amazon.com/blogs/aws/managed-spot-training-save-up-to-90-on-your-amazon-sagemaker-training-jobs/" rel="nofollow noreferrer">Managed Spot Training: Save Up to 90% On Your Amazon SageMaker Training Jobs</a> says:</p>
  <blockquote>
  <p>Setting it up is extremely simple, as it should be when working with a fully-managed service:</p>
  <ul>
  <li>If you’re using the console, just switch the feature on.</li>
  <li>If you’re working with the Amazon SageMaker SDK, <strong>just set the train_use_spot_instances to true</strong> in the Estimator constructor.</li>
  </ul>
  </blockquote>
  <p><a href="https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html#sagemaker.estimator.Estimator" rel="nofollow noreferrer">SageMaker SDK sagemaker.estimator.Estimator</a> says:</p>
  <blockquote>
  <ul>
  <li>use_spot_instances (bool) –
  Specifies whether to use SageMaker Managed Spot instances for training. If enabled then the max_wait arg should also be set.</li>
  <li>max_wait (int) –
  Timeout in seconds waiting for spot training instances (default: None). After this amount of time Amazon SageMaker will stop waiting for Spot instances to become available (default: None).</li>
  </ul>
  </blockquote>
  <p>As per the documentations, run below.</p>
  <pre><code>from sagemaker.tensorflow import TensorFlow
  
  
  estimator = TensorFlow(
      entry_point=&quot;fashion_mnist_training.py&quot;,
      source_dir=&quot;src&quot;,
      metric_definitions=metric_definitions,
      hyperparameters=hyperparameters,
      role=role,
      input_mode='File',
      framework_version=&quot;2.3.1&quot;,
      py_version=&quot;py37&quot;,
      instance_count=1,
      instance_type=&quot;ml.m5.xlarge&quot;,
      use_spot_instances=True,
      max_wait= 23 * 60 * 60, 
      base_job_name=base_job_name,
      checkpoint_s3_uri=checkpoint_s3_uri,
      model_dir=False  # To avoid duplicate 'model_dir' command line argument
  )
  </code></pre>
  <p>However, error is caused.</p>
  <pre><code>ClientError: An error occurred (ValidationException) when calling the CreateTrainingJob operation: Invalid MaxWaitTimeInSeconds. It must be present and be greater than or equal to MaxRuntimeInSeconds
  </code></pre>