简体   繁体   English

在 MLflow 中注册 SageMaker model

[英]Register SageMaker model in MLflow

MLflow can be used to track (hyper)parameters and metrics when training machine learning models. MLflow 可用于在训练机器学习模型时跟踪(超)参数和指标。 It stores the trained model as an artifact for every experiment.它将经过训练的 model 存储为每个实验的工件。 These models then can be directly deployed as SageMaker endpoints .然后可以将这些模型直接部署为SageMaker 端点

Is it possible to do it the other way around, too, ie to register models trained in SageMaker into MLflow?是否也可以反过来做,即将在 SageMaker 中训练的模型注册到 MLflow 中?

获取输入 object 的`dtype 与预期的 dtype 不匹配<u0` when invoking mlflow-deployed nlp model in sagemaker< div><div id="text_translate"><p> 我使用 MLflow 的sagemaker.deploy()在 SageMaker 中部署了一个 Huggingface Transformer model。</p><p> 在记录 model 时,我使用infer_signature(np.array(test_example), loaded_model.predict(test_example))来推断输入和 output 签名。</p><p> Model部署成功。 当尝试查询 model 时,我得到了ModelError (下面的完整回溯)。</p><p> 要查询test_example ,我使用的 test_example 与用于infer_signature()的完全相同:</p><p> test_example = [['This is the subject', 'This is the body']]</p><p> 唯一的区别是,在查询已部署的 model 时,我没有将测试示例包装在np.array()中,因为它不是json可序列化的。</p><p> 为了查询 model,我尝试了两种不同的方法:</p><pre class="lang-py prettyprint-override"> import boto3 SAGEMAKER_REGION = 'us-west-2' MODEL_NAME = '...' client = boto3.client("sagemaker-runtime", region_name=SAGEMAKER_REGION) # Approach 1 client.invoke_endpoint( EndpointName=MODEL_NAME, Body=json.dumps(test_example), ContentType="application/json", ) # Approach 2 client.invoke_endpoint( EndpointName=MODEL_NAME, Body=pd.DataFrame(test_example).to_json(orient="split"), ContentType="application/json; format=pandas-split", )</pre><p> 但它们会导致相同的错误。</p><p> 将不胜感激您的建议。</p><p> 谢谢!</p><p> 注意:我使用的是 Python 3 并且所有<strong>字符串都是 unicode</strong> 。</p><pre class="lang-py prettyprint-override"> --------------------------------------------------------------------------- ModelError Traceback (most recent call last) <ipython-input-89-d09862a5f494> in <module> 2 EndpointName=MODEL_NAME, 3 Body=test_example, ----> 4 ContentType="application/json; format=pandas-split", 5 ) ~/anaconda3/envs/amazonei_tensorflow_p36/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs) 393 "%s() only accepts keyword arguments." % py_operation_name) 394 # The "self" in this scope is referring to the BaseClient. --> 395 return self._make_api_call(operation_name, kwargs) 396 397 _api_call.__name__ = str(py_operation_name) ~/anaconda3/envs/amazonei_tensorflow_p36/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params) 723 error_code = parsed_response.get("Error", {}).get("Code") 724 error_class = self.exceptions.from_code(error_code) --> 725 raise error_class(parsed_response, operation_name) 726 else: 727 return parsed_response ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{"error_code": "BAD_REQUEST", "message": "dtype of input object does not match expected dtype <U0"}". See https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEventViewer:group=/aws/sagemaker/Endpoints/bec-sagemaker-model-test-app in account 543052680787 for more information.</pre><p> 环境信息:</p><pre class="lang-py prettyprint-override"> {'channels': ['defaults', 'conda-forge', 'pytorch'], 'dependencies': ['python=3.6.10', 'pip==21.3.1', 'pytorch=1.10.2', 'cudatoolkit=10.2', {'pip': ['mlflow==1.22.0', 'transformers==4.17.0', 'datasets==1.18.4', 'cloudpickle==1.3.0']}], 'name': 'bert_bec_test_env'}</pre></div></u0`> - Getting `dtype of input object does not match expected dtype <U0` when invoking MLflow-deployed NLP model in SageMaker

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取输入 object 的`dtype 与预期的 dtype 不匹配<u0` when invoking mlflow-deployed nlp model in sagemaker< div><div id="text_translate"><p> 我使用 MLflow 的sagemaker.deploy()在 SageMaker 中部署了一个 Huggingface Transformer model。</p><p> 在记录 model 时,我使用infer_signature(np.array(test_example), loaded_model.predict(test_example))来推断输入和 output 签名。</p><p> Model部署成功。 当尝试查询 model 时,我得到了ModelError (下面的完整回溯)。</p><p> 要查询test_example ,我使用的 test_example 与用于infer_signature()的完全相同:</p><p> test_example = [['This is the subject', 'This is the body']]</p><p> 唯一的区别是,在查询已部署的 model 时,我没有将测试示例包装在np.array()中,因为它不是json可序列化的。</p><p> 为了查询 model,我尝试了两种不同的方法:</p><pre class="lang-py prettyprint-override"> import boto3 SAGEMAKER_REGION = 'us-west-2' MODEL_NAME = '...' client = boto3.client("sagemaker-runtime", region_name=SAGEMAKER_REGION) # Approach 1 client.invoke_endpoint( EndpointName=MODEL_NAME, Body=json.dumps(test_example), ContentType="application/json", ) # Approach 2 client.invoke_endpoint( EndpointName=MODEL_NAME, Body=pd.DataFrame(test_example).to_json(orient="split"), ContentType="application/json; format=pandas-split", )</pre><p> 但它们会导致相同的错误。</p><p> 将不胜感激您的建议。</p><p> 谢谢!</p><p> 注意:我使用的是 Python 3 并且所有<strong>字符串都是 unicode</strong> 。</p><pre class="lang-py prettyprint-override"> --------------------------------------------------------------------------- ModelError Traceback (most recent call last) <ipython-input-89-d09862a5f494> in <module> 2 EndpointName=MODEL_NAME, 3 Body=test_example, ----> 4 ContentType="application/json; format=pandas-split", 5 ) ~/anaconda3/envs/amazonei_tensorflow_p36/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs) 393 "%s() only accepts keyword arguments." % py_operation_name) 394 # The "self" in this scope is referring to the BaseClient. --> 395 return self._make_api_call(operation_name, kwargs) 396 397 _api_call.__name__ = str(py_operation_name) ~/anaconda3/envs/amazonei_tensorflow_p36/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params) 723 error_code = parsed_response.get("Error", {}).get("Code") 724 error_class = self.exceptions.from_code(error_code) --> 725 raise error_class(parsed_response, operation_name) 726 else: 727 return parsed_response ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{"error_code": "BAD_REQUEST", "message": "dtype of input object does not match expected dtype <U0"}". See https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEventViewer:group=/aws/sagemaker/Endpoints/bec-sagemaker-model-test-app in account 543052680787 for more information.</pre><p> 环境信息:</p><pre class="lang-py prettyprint-override"> {'channels': ['defaults', 'conda-forge', 'pytorch'], 'dependencies': ['python=3.6.10', 'pip==21.3.1', 'pytorch=1.10.2', 'cudatoolkit=10.2', {'pip': ['mlflow==1.22.0', 'transformers==4.17.0', 'datasets==1.18.4', 'cloudpickle==1.3.0']}], 'name': 'bert_bec_test_env'}</pre></div></u0`> - Getting `dtype of input object does not match expected dtype <U0` when invoking MLflow-deployed NLP model in SageMaker mlflow 无法从 model 注册表中获取 model - mlflow cannot fetch model from model registry 为 PyTorch Model 调用 SageMaker 端点 - Invoking SageMaker Endpoint for PyTorch Model 创建 SageMaker 时出现验证错误 Model - ValidationError when creating a SageMaker Model 贤者推理:如何加载model - Sagemaker inference : how to load model 从 SageMaker model 端点获取 model 元数据 - Getting model metadata from SageMaker model endpoint Model SageMaker中的管理:Model Package组的使用 - Model Management in SageMaker : Use of Model Package Group AWS SageMaker Pipeline Model 端点部署失败 - AWS SageMaker Pipeline Model endpoint deployment failing 部署 TensorFlow 概率回归 model 作为 Sagemaker 端点 - Deploy TensorFlow probability regression model as Sagemaker endpoint 加载时运行 SageMaker Batch 转换失败 model - Run SageMaker Batch transform failed on loading model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM