Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
"This model is not available on the selected Azure OpenAI Service resource." error, but I think it is. Why did I miss?
I deployed a finetuned GPT 4o mini model on Azure, region northcentralus
.
I getting this error in the Azure portal when trying to edit it (I wanted to change the max hit rate):
This model is not available on the selected Azure OpenAI Service resource. Learn more about model availability.
My selected resource in Azure portal is in northcentralus
:
However, https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#fine-tuning-models states that finetuned GPT 4o mini model is available in Azure, region northcentralus
:
What did I miss? Why am I getting a "This model is not available on the selected Azure OpenAI Service resource" error?
I deployed the finetuned GPT 4o mini model on following Azure's tutorial on fine-tuning GPT. Code for the deployment phase:
# Deploy fine-tuned model
import json
import requests
token = '[redacted]'
subscription = '[redacted]'
resource_group = "[redacted]"
resource_name = "[redacted]"
model_deployment_name = "gpt-4o-mini-2024-07-18-ft" # Custom deployment name you chose for your fine-tuning model
deploy_params = {'api-version': "2023-05-01"}
deploy_headers = {'Authorization': 'Bearer {}'.format(token), 'Content-Type': 'application/json'}
deploy_data = {
"sku": {"name": "standard", "capacity": 1},
"properties": {
"model": {
"format": "OpenAI",
"name": "gpt-4o-mini-2024-07-18.ft-[redacted]", #retrieve this value from the previous call, it will look like gpt-4o-mini-2024-07-18.ft-[redacted]
"version": "1"
}
}
}
deploy_data = json.dumps(deploy_data)
request_url = f'https://management.azure.com/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{resource_name}/deployments/{model_deployment_name}'
print('Creating a new deployment...')
r = requests.put(request_url, params=deploy_params, headers=deploy_headers, data=deploy_data)
print(r)
print(r.reason)
print(r.json())
The token was generated via az account get-access-token
.
Crossposts:
- https://serverfault.com/q/1179143/126950
- https://redd.it/1jzm8q6
- https://redd.it/1jzm8io
- https://redd.it/1jzm8dz
1 answer
I've given up on that Azure UI, here's the Python code to do it. It requires a token generated via az account get-access-token
.
import json
import requests
new_capacity = 3 # Change this number to your desired capacity. 3 means 3000 tokens/minute.
# Authentication and resource identification
token = "YOUR_BEARER_TOKEN" # Replace with your actual token
subscription = ''
resource_group = ""
resource_name = ""
model_deployment_name = ""
# API parameters and headers
update_params = {'api-version': "2023-05-01"}
update_headers = {'Authorization': 'Bearer {}'.format(token), 'Content-Type': 'application/json'}
# First, get the current deployment to preserve its configuration
request_url = f'https://management.azure.com/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{resource_name}/deployments/{model_deployment_name}'
r = requests.get(request_url, params=update_params, headers=update_headers)
if r.status_code != 200:
print(f"Failed to get current deployment: {r.status_code}")
print(r.reason)
if hasattr(r, 'json'):
print(r.json())
exit(1)
# Get the current deployment configuration
current_deployment = r.json()
# Update only the capacity in the configuration
update_data = {
"sku": {
"name": current_deployment["sku"]["name"],
"capacity": new_capacity
},
"properties": current_deployment["properties"]
}
update_data = json.dumps(update_data)
print('Updating deployment capacity...')
# Use PUT to update the deployment
r = requests.put(request_url, params=update_params, headers=update_headers, data=update_data)
print(f"Status code: {r.status_code}")
print(f"Reason: {r.reason}")
if hasattr(r, 'json'):
print(r.json())
Takes a few seconds to get updated.
0 comment threads