ModelErrorResponseException:未经授权的Azure ML授权错误

时间:2020-03-12 12:54:09

标签: python azure-machine-learning-service

在azure ml笔记本中成功运行训练估计器并进行了实验之后,尝试注册模型时出现未经授权的错误。当我查看天蓝色门户中的估计器或“模型”选项卡时,我还会看到一个未经授权的栏会在顶部弹出。

这似乎是一个资源组问题,但我只有一个资源组。有人遇到过这个问题吗?

成功的实验:

from azureml.core.experiment import Experiment

script_params = {
#     '--num_epochs': 3,
    '--output_dir': './outputs'
}

estimator = PyTorch(source_directory=os.path.join(os.getcwd(), 'Estimator'), 
                    script_params=script_params,
                    compute_target=compute_target,
                    entry_script='train.py',
                    use_gpu=True,
                    pip_packages=['pillow==5.4.1', 'torch', 'numpy'])

experiment_name = 'pytorch-rnn-generator'
experiment = Experiment(ws, name=experiment_name)

run = experiment.submit(estimator)
run.wait_for_completion(show_output=True)

模型注册:

model = run.register_model(model_name='rnn-tv-script-gen', model_path='outputs/')

堆栈跟踪:

ModelErrorResponseException               Traceback (most recent call last)
<ipython-input-6-178d7ee9830a> in <module>
      1 from azureml.core.model import Model
      2 
----> 3 model = run.register_model(model_name='rnn-tv-script-gen', model_path='outputs/')
      4 
      5 servive = Model.deploy(ws, 

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/run.py in register_model(self, model_name, model_path, tags, properties, model_framework, model_framework_version, description, datasets, sample_input_dataset, sample_output_dataset, resource_configuration, **kwargs)
   1988             model_name, model_path, tags, properties, model_framework, model_framework_version,
   1989             description=description, datasets=datasets, unpack=False, sample_input_dataset=sample_input_dataset,
-> 1990             sample_output_dataset=sample_output_dataset, resource_configuration=resource_configuration, **kwargs)
   1991 
   1992     def _update_dataset_lineage(self, datasets):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_run_impl/run_history_facade.py in register_model(self, model_name, model_path, tags, properties, model_framework, model_framework_version, asset_id, sample_input_dataset, sample_output_dataset, resource_configuration, **kwargs)
    386                                              artifacts,
    387                                              metadata_dict=metadata_dict,
--> 388                                              run_id=self._run_id)
    389             asset_id = asset.id
    390         else:

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/assets_client.py in create_asset(self, model_name, artifact_values, metadata_dict, project_id, run_id, tags, properties)
     50                    "meta": metadata_dict,
     51                    "CreatedTime": created_time}
---> 52         return self._execute_with_workspace_arguments(self._client.asset.create, payload)
     53 
     54     def get_assets_by_run_id_and_name(self, run_id, name):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/workspace_client.py in _execute_with_workspace_arguments(self, func, *args, **kwargs)
     69 
     70     def _execute_with_workspace_arguments(self, func, *args, **kwargs):
---> 71         return self._execute_with_arguments(func, copy.deepcopy(self._workspace_arguments), *args, **kwargs)
     72 
     73     def _execute_with_arguments(self, func, args_list, *args, **kwargs):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/workspace_client.py in _execute_with_arguments(self, func, args_list, *args, **kwargs)
     85                 return self._call_paginated_api(func, *args_list, **kwargs)
     86             else:
---> 87                 return self._call_api(func, *args_list, **kwargs)
     88         except ErrorResponseException as e:
     89             raise ServiceException(e)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/clientbase.py in _call_api(self, func, *args, **kwargs)
    224                 return AsyncTask(future, _ident=ident, _parent_logger=self._logger)
    225             else:
--> 226                 return self._execute_with_base_arguments(func, *args, **kwargs)
    227 
    228     def _call_paginated_api(self, func, *args, **kwargs):

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/clientbase.py in _execute_with_base_arguments(self, func, *args, **kwargs)
    277         total_retry = 0 if self.retries < 0 else self.retries
    278         return ClientBase._execute_func_internal(
--> 279             back_off, total_retry, self._logger, func, _noop_reset, *args, **kwargs)
    280 
    281     @classmethod

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/clientbase.py in _execute_func_internal(cls, back_off, total_retry, logger, func, reset_func, *args, **kwargs)
    292                 return func(*args, **kwargs)
    293             except Exception as error:
--> 294                 left_retry = cls._handle_retry(back_off, left_retry, total_retry, error, logger, func)
    295 
    296             reset_func(*args, **kwargs)  # reset_func is expected to undo any side effects from a failed func call.

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/clientbase.py in _handle_retry(cls, back_off, left_retry, total_retry, error, logger, func)
    341                 back_off = DEFAULT_503_BACKOFF
    342             elif error.response.status_code < 500:
--> 343                 raise error
    344         elif not isinstance(error, RETRY_EXCEPTIONS):
    345             raise error

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/clientbase.py in _execute_func_internal(cls, back_off, total_retry, logger, func, reset_func, *args, **kwargs)
    290         while left_retry >= 0:
    291             try:
--> 292                 return func(*args, **kwargs)
    293             except Exception as error:
    294                 left_retry = cls._handle_retry(back_off, left_retry, total_retry, error, logger, func)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/_restclient/operations/asset_operations.py in create(self, subscription_id, resource_group_name, workspace, asset, custom_headers, raw, **operation_config)
     88 
     89         if response.status_code not in [200]:
---> 90             raise models.ModelErrorResponseException(self._deserialize, response)
     91 
     92         deserialized = None

ModelErrorResponseException: Unauthorized

1 个答案:

答案 0 :(得分:0)

绝对是一个奇怪的错误。似乎您使用this guide作为参考。不知道您的train.py是什么样,我很想知道您是否:

  1. 在不进行任何更改的情况下运行指南的ipynb时出现错误?
  2. 您的代码中还有下面的代码段吗?
    os.makedirs(args.output_dir, exist_ok=True)
    torch.save(model, os.path.join(args.output_dir, 'model.pt'))
    
  3. 如果您尝试下载文件,如this docs section的第二个片段中所示,会得到类似的错误吗?
相关问题