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

Access Denied while trying to run local training

Open gautiese opened this issue 8 years ago • 1 comments

Please fill out the form below.

System Information

  • Framework (e.g. TensorFlow) / Algorithm (e.g. KMeans): Tensorflow
  • Framework Version: 1.11
  • Python Version: 2
  • CPU or GPU: CPU
  • Python SDK Version:
  • Are you using a custom image: No

Describe the problem

I cant seem to get the local training mode to run properly. This is the error I get:

Creating tmphdxh84ls_algo-1-RNNI9_1 ... 
Attaching to tmphdxh84ls_algo-1-RNNI9_12mdone
algo-1-RNNI9_1  | 2018-10-26 04:33:20,756 INFO - root - running container entrypoint
algo-1-RNNI9_1  | 2018-10-26 04:33:20,756 INFO - root - starting train task
algo-1-RNNI9_1  | 2018-10-26 04:33:20,762 INFO - container_support.training - Training starting
algo-1-RNNI9_1  | Downloading s3://sagemaker-us-east-2-180860645755/WASP-base-model-2018-10-26-04-32-35-912/source/sourcedir.tar.gz to /tmp/script.tar.gz
algo-1-RNNI9_1  | 2018-10-26 04:33:21,672 ERROR - container_support.training - uncaught exception during training: An error occurred (403) when calling the HeadObject operation: Forbidden
algo-1-RNNI9_1  | Traceback (most recent call last):
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/container_support/training.py", line 36, in start
algo-1-RNNI9_1  |     fw.train()
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/tf_container/train_entry_point.py", line 147, in train
algo-1-RNNI9_1  |     env.download_user_module()
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/container_support/environment.py", line 89, in download_user_module
algo-1-RNNI9_1  |     cs.download_s3_resource(self.user_script_archive, tmp)
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/container_support/utils.py", line 41, in download_s3_resource
algo-1-RNNI9_1  |     script_bucket.download_file(script_key_name, target)
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/boto3/s3/inject.py", line 246, in bucket_download_file
algo-1-RNNI9_1  |     ExtraArgs=ExtraArgs, Callback=Callback, Config=Config)
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/boto3/s3/inject.py", line 172, in download_file
algo-1-RNNI9_1  |     extra_args=ExtraArgs, callback=Callback)
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 307, in download_file
algo-1-RNNI9_1  |     future.result()
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/s3transfer/futures.py", line 73, in result
algo-1-RNNI9_1  |     return self._coordinator.result()
algo-1-RNNI9_1  |   File "/usr/local/lib/python2.7/dist-packages/s3transfer/futures.py", line 233, in result
algo-1-RNNI9_1  |     raise self._exception
algo-1-RNNI9_1  | ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
algo-1-RNNI9_1  | 
algo-1-RNNI9_1  | 
tmphdxh84ls_algo-1-RNNI9_1 exited with code 1
Aborting on container exit...
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/local/image.py in train(self, input_data_config, hyperparameters, job_name)
    121         try:
--> 122             _stream_output(process)
    123         except RuntimeError as e:

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/local/image.py in _stream_output(process)
    547     if exit_code != 0:
--> 548         raise RuntimeError("Process exited with code: %s" % exit_code)
    549 

RuntimeError: Process exited with code: 1

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
<ipython-input-4-593321685768> in <module>()
     10                                base_job_name="WASP-base-model")
     11 
---> 12 new_watch_estimator.fit("s3://sagemaker-us-east-2-180860645755/WASP/data/")

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/tensorflow/estimator.py in fit(self, inputs, wait, logs, job_name, run_tensorboard_locally)
    251                 tensorboard.join()
    252         else:
--> 253             fit_super()
    254 
    255     @classmethod

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/tensorflow/estimator.py in fit_super()
    233         """
    234         def fit_super():
--> 235             super(TensorFlow, self).fit(inputs, wait, logs, job_name)
    236 
    237         if run_tensorboard_locally and wait is False:

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/estimator.py in fit(self, inputs, wait, logs, job_name)
    190         self._prepare_for_training(job_name=job_name)
    191 
--> 192         self.latest_training_job = _TrainingJob.start_new(self, inputs)
    193         if wait:
    194             self.latest_training_job.wait(logs=logs)

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/estimator.py in start_new(cls, estimator, inputs)
    432                                           resource_config=config['resource_config'], vpc_config=config['vpc_config'],
    433                                           hyperparameters=hyperparameters, stop_condition=config['stop_condition'],
--> 434                                           tags=estimator.tags)
    435 
    436         return cls(estimator.sagemaker_session, estimator._current_job_name)

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/session.py in train(self, image, input_mode, input_config, role, job_name, output_config, resource_config, vpc_config, hyperparameters, stop_condition, tags)
    277         LOGGER.info('Creating training-job with name: {}'.format(job_name))
    278         LOGGER.debug('train request: {}'.format(json.dumps(train_request, indent=4)))
--> 279         self.sagemaker_client.create_training_job(**train_request)
    280 
    281     def tune(self, job_name, strategy, objective_type, objective_metric_name,

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/local/local_session.py in create_training_job(self, TrainingJobName, AlgorithmSpecification, InputDataConfig, OutputDataConfig, ResourceConfig, **kwargs)
     72         training_job = _LocalTrainingJob(container)
     73         hyperparameters = kwargs['HyperParameters'] if 'HyperParameters' in kwargs else {}
---> 74         training_job.start(InputDataConfig, hyperparameters, TrainingJobName)
     75 
     76         LocalSagemakerClient._training_jobs[TrainingJobName] = training_job

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/local/entities.py in start(self, input_data_config, hyperparameters, job_name)
     63         self.state = self._TRAINING
     64 
---> 65         self.model_artifacts = self.container.train(input_data_config, hyperparameters, job_name)
     66         self.end = datetime.datetime.now()
     67         self.state = self._COMPLETED

~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/sagemaker/local/image.py in train(self, input_data_config, hyperparameters, job_name)
    125             # which contains the exit code and append the command line to it.
    126             msg = "Failed to run: %s, %s" % (compose_command, str(e))
--> 127             raise RuntimeError(msg)
    128 
    129         s3_artifacts = self.retrieve_artifacts(compose_data)

RuntimeError: Failed to run: ['docker-compose', '-f', '/tmp/tmphdxh84ls/docker-compose.yaml', 'up', '--build', '--abort-on-container-exit'], Process exited with code: 1

This was my call from the SDK:

from sagemaker.tensorflow import TensorFlow

new_watch_estimator = TensorFlow(entry_point='final_model.py',
                               role=role,
                               training_steps= 1,   
                               evaluation_steps= 1,
                               hyperparameters=hyperparameters,
                               train_instance_count=1,
                               train_instance_type='local',
                               base_job_name="WASP-base-model")

new_watch_estimator.fit("s3://sagemaker-us-east-2-180860645755/WASP/data/")

gautiese avatar Oct 26 '18 04:10 gautiese

Hi @gautiese ,

It seems that the your role does not have access to the bucker s3://sagemaker-us-east-2-180860645755/WASP/data/. For more information on how to configure your role, please see https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html

Thanks for using SageMaker!

Best,

Márcio

mvsusp avatar Oct 27 '18 02:10 mvsusp