

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# Implante um modelo compilado usando o Boto3
<a name="neo-deployment-hosting-services-boto3"></a>

Você deve atender à seção de [pré-requisitos](https://docs.aws.amazon.com//sagemaker/latest/dg/neo-deployment-hosting-services-prerequisites) se o modelo tiver sido compilado usando AWS SDK para Python (Boto3) o console Amazon AI ou o console Amazon SageMaker AI. AWS CLI Siga as etapas abaixo para criar e implantar um modelo SageMaker neocompilado usando o [SDK da Amazon Web Services para Python (Boto3)](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html). 

**Topics**
+ [Implantar o modelo](#neo-deployment-hosting-services-boto3-steps)

## Implantar o modelo
<a name="neo-deployment-hosting-services-boto3-steps"></a>

Depois de satisfazer os [pré-requisitos](https://docs.aws.amazon.com//sagemaker/latest/dg/neo-deployment-hosting-services-prerequisites), use o`create_model`, e. `create_enpoint_config` `create_endpoint` APIs 

O exemplo a seguir mostra como usá-los para APIs implantar um modelo compilado com o Neo: 

```
import boto3
client = boto3.client('sagemaker')

# create sagemaker model
create_model_api_response = client.create_model(
                                    ModelName='my-sagemaker-model',
                                    PrimaryContainer={
                                        'Image': <insert the ECR Image URI>,
                                        'ModelDataUrl': 's3://path/to/model/artifact/model.tar.gz',
                                        'Environment': {}
                                    },
                                    ExecutionRoleArn='ARN for AmazonSageMaker-ExecutionRole'
                            )

print ("create_model API response", create_model_api_response)

# create sagemaker endpoint config
create_endpoint_config_api_response = client.create_endpoint_config(
                                            EndpointConfigName='sagemaker-neomxnet-endpoint-configuration',
                                            ProductionVariants=[
                                                {
                                                    'VariantName': <provide your variant name>,
                                                    'ModelName': 'my-sagemaker-model',
                                                    'InitialInstanceCount': 1,
                                                    'InstanceType': <provide your instance type here>
                                                },
                                            ]
                                       )

print ("create_endpoint_config API response", create_endpoint_config_api_response)

# create sagemaker endpoint
create_endpoint_api_response = client.create_endpoint(
                                    EndpointName='provide your endpoint name',
                                    EndpointConfigName=<insert your endpoint config name>,
                                )

print ("create_endpoint API response", create_endpoint_api_response)
```

**nota**  
As políticas `AmazonSageMakerFullAccess` e `AmazonS3ReadOnlyAccess` devem ser anexadas à função IAM `AmazonSageMaker-ExecutionRole`. 

Para obter a sintaxe completa de `create_model``create_endpoint_config`, `create_endpoint` APIs, e, consulte [https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_model](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_model), e [https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_endpoint](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_endpoint), respectivamente. 

Se você não treinou seu modelo usando SageMaker IA, especifique as seguintes variáveis de ambiente: 

------
#### [ MXNet and PyTorch ]

```
"Environment": {
    "SAGEMAKER_PROGRAM": "inference.py",
    "SAGEMAKER_SUBMIT_DIRECTORY": "/opt/ml/model/code",
    "SAGEMAKER_CONTAINER_LOG_LEVEL": "20",
    "SAGEMAKER_REGION": "insert your region",
    "MMS_DEFAULT_RESPONSE_TIMEOUT": "500"
}
```

------
#### [ TensorFlow ]

```
"Environment": {
    "SAGEMAKER_PROGRAM": "inference.py",
    "SAGEMAKER_SUBMIT_DIRECTORY": "/opt/ml/model/code",
    "SAGEMAKER_CONTAINER_LOG_LEVEL": "20",
    "SAGEMAKER_REGION": "insert your region"
}
```

------

 Se você treinou seu modelo usando SageMaker IA, especifique a variável de ambiente `SAGEMAKER_SUBMIT_DIRECTORY` como o URI completo do bucket do Amazon S3 que contém o script de treinamento. 