C2-W2 cannot deploy model

running this code snippet

%%time

predictor = model.deploy(initial_instance_count=1,
instance_type=‘ml.m5.large’,
endpoint_name=pytorch_endpoint_name)

yields a very unclear error.


ClientError Traceback (most recent call last)
in

/opt/conda/lib/python3.7/site-packages/sagemaker/model.py in deploy(self, initial_instance_count, instance_type, serializer, deserializer, accelerator_type, endpoint_name, tags, kms_key, wait, data_capture_config, **kwargs)
761 self._base_name = “-”.join((self._base_name, compiled_model_suffix))
762
→ 763 self._create_sagemaker_model(instance_type, accelerator_type, tags)
764 production_variant = sagemaker.production_variant(
765 self.name, instance_type, initial_instance_count, accelerator_type=accelerator_type

/opt/conda/lib/python3.7/site-packages/sagemaker/model.py in _create_sagemaker_model(self, instance_type, accelerator_type, tags)
315 /api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags
316 “”"
→ 317 container_def = self.prepare_container_def(instance_type, accelerator_type=accelerator_type)
318
319 self._ensure_base_name_if_needed(container_def[“Image”])

/opt/conda/lib/python3.7/site-packages/sagemaker/pytorch/model.py in prepare_container_def(self, instance_type, accelerator_type)
237
238 deploy_key_prefix = model_code_key_prefix(self.key_prefix, self.name, deploy_image)
→ 239 self._upload_code(deploy_key_prefix, repack=self._is_mms_version())
240 deploy_env = dict(self.env)
241 deploy_env.update(self._framework_env_vars())

/opt/conda/lib/python3.7/site-packages/sagemaker/model.py in _upload_code(self, key_prefix, repack)
1136 repacked_model_uri=repacked_model_data,
1137 sagemaker_session=self.sagemaker_session,
→ 1138 kms_key=self.model_kms_key,
1139 )
1140

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in repack_model(inference_script, source_directory, dependencies, model_uri, repacked_model_uri, sagemaker_session, kms_key)
410
411 with _tmpdir() as tmp:
→ 412 model_dir = _extract_model(model_uri, sagemaker_session, tmp)
413
414 _create_or_update_code_dir(

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in _extract_model(model_uri, sagemaker_session, tmp)
484 if model_uri.lower().startswith(“s3://”):
485 local_model_path = os.path.join(tmp, “tar_file”)
→ 486 download_file_from_url(model_uri, local_model_path, sagemaker_session)
487 else:
488 local_model_path = model_uri.replace(“file://”, “”)

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in download_file_from_url(url, dst, sagemaker_session)
497 bucket, key = url.netloc, url.path.lstrip(“/”)
498
→ 499 download_file(bucket, key, dst, sagemaker_session)
500
501

/opt/conda/lib/python3.7/site-packages/sagemaker/utils.py in download_file(bucket_name, path, target, sagemaker_session)
515 s3 = boto_session.resource(“s3”, region_name=sagemaker_session.boto_region_name)
516 bucket = s3.Bucket(bucket_name)
→ 517 bucket.download_file(path, target)
518
519

/opt/conda/lib/python3.7/site-packages/boto3/s3/inject.py in bucket_download_file(self, Key, Filename, ExtraArgs, Callback, Config)
281 ExtraArgs=ExtraArgs,
282 Callback=Callback,
→ 283 Config=Config,
284 )
285

/opt/conda/lib/python3.7/site-packages/boto3/s3/inject.py in download_file(self, Bucket, Key, Filename, ExtraArgs, Callback, Config)
193 filename=Filename,
194 extra_args=ExtraArgs,
→ 195 callback=Callback,
196 )
197

/opt/conda/lib/python3.7/site-packages/boto3/s3/transfer.py in download_file(self, bucket, key, filename, extra_args, callback)
318 )
319 try:
→ 320 future.result()
321 # This is for backwards compatibility where when retries are
322 # exceeded we need to throw the same error from boto3 instead of

/opt/conda/lib/python3.7/site-packages/s3transfer/futures.py in result(self)
101 # however if a KeyboardInterrupt is raised we want want to exit
102 # out of this and propagate the exception.
→ 103 return self._coordinator.result()
104 except KeyboardInterrupt as e:
105 self.cancel()

/opt/conda/lib/python3.7/site-packages/s3transfer/futures.py in result(self)
264 # final result.
265 if self._exception:
→ 266 raise self._exception
267 return self._result
268

/opt/conda/lib/python3.7/site-packages/s3transfer/tasks.py in _main(self, transfer_future, **kwargs)
267 # Call the submit method to start submitting tasks to execute the
268 # transfer.
→ 269 self._submit(transfer_future=transfer_future, **kwargs)
270 except BaseException as e:
271 # If there was an exception raised during the submission of task

/opt/conda/lib/python3.7/site-packages/s3transfer/download.py in _submit(self, client, config, osutil, request_executor, io_executor, transfer_future, bandwidth_limiter)
355 Bucket=transfer_future.meta.call_args.bucket,
356 Key=transfer_future.meta.call_args.key,
→ 357 **transfer_future.meta.call_args.extra_args,
358 )
359 transfer_future.meta.provide_transfer_size(

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
506 )
507 # The “self” in this scope is referring to the BaseClient.
→ 508 return self._make_api_call(operation_name, kwargs)
509
510 _api_call.name = str(py_operation_name)

/opt/conda/lib/python3.7/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
913 error_code = parsed_response.get(“Error”, {}).get(“Code”)
914 error_class = self.exceptions.from_code(error_code)
→ 915 raise error_class(parsed_response, operation_name)
916 else:
917 return parsed_response

ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

Hi @PDS_Mentors,

Can one of you help here ?

Thanks,
Mubsi

Hi @Sacha_van_Weeren, thanks for sharing this issue!

Your code snippet is right. Have you checked back if you have accidentally changed the pytorch_endpoint_name object?

Cheers!

1 Like

Thanks for your mail. I am quite sure I did everything as intended. Yesterday I restarted the lab and then everything worked smoothly and got 100% score.

2 Likes