Share via

Azure SQL Managed Instance PREDICT with an ONNX model

2022-04-20T13:14:26.51+00:00

I repeat the example from https://learn.microsoft.com/en-us/azure/azure-sql-edge/deploy-onnx "Deploy and make predictions with an ONNX model and SQL machine learning" In this quickstart, you'll learn how to train a model, convert it to ONNX, deploy it to Azure SQL Edge, and then run native PREDICT on data using the uploaded ONNX model.

Successfully create a model using Python, convert to onnx format, I test the model using Python, save the model to the database, load the necessary data and try to execute the SQL query
USE onnx
DECLARE @默 VARBINARY(max) = (
SELECT DATA
FROM dbo.models
WHERE id = 1
);
WITH predict_input
AS (
SELECT TOP (1000) [id]
, CRIM
, ZN
, INDUS
, CHAS
, NOX
, RM
, AGE
, DIS
, RAD
, TAX
, PTRATIO
, B
, LSTAT
FROM [dbo].[features]
)
SELECT predict_input.id
, p.variable1 AS MEDV
FROM PREDICT(MODEL = @默 , DATA = predict_input, RUNTIME=ONNX) WITH (variable1 FLOAT) AS p;

As a result I get an error Msg 102, Level 16, State 5, Line 27 Incorrect syntax near 'RUNTIME'.

I can't figure out what's wrong. The documentation clearly says "The RUNTIME = ONNX argument is only available in Azure SQL Edge, Azure Synapse Analytics, and is in Preview in Azure SQL Managed Instance."

Azure SQL Database
Azure Machine Learning
Azure SQL Edge
Azure SQL Edge

An Azure service that provides a small-footprint, edge-optimized data engine with built-in artificial intelligence. Previously known as Azure SQL Database Edge.

0 comments No comments

Answer accepted by question author

Alberto Morillo 35,506 Reputation points MVP Volunteer Moderator
2022-04-20T13:29:53.25+00:00

I think there is a misunderstanding here. The quickstart article named "Deploy and make predictions with an ONNX model and SQL machine learning" can be successfully implemented only with Azure SQL Edge and cannot be implemented with Azure SQL Managed Instance.

You cannot have an ONNX model and make predictions with it on Azure SQL Managed Instance. Please deploy Azure SQL Edge on an IoT device using this documentation.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Агарков Константин 26 Reputation points
    2022-04-21T08:13:34.65+00:00

    Thanks for the answer.
    In the document "Native scoring using the PREDICT T-SQL function with SQL machine learning"
    https://learn.microsoft.com/en-us/sql/machine-learning/predictions/native-scoring-predict-transact-sql?view=sql-server-ver15
    it says that Azure SQL Managed Instance supports the onnx format

    In the document "PREDICT (Transact-SQL)"
    https://learn.microsoft.com/en-us/sql/t-sql/queries/predict-transact-sql?view=sql-server-ver15
    the following is written "Important. Support for PREDICT is in Preview in Azure SQL Managed Instance"

    As far as I understand, PREDICT with support for the onnx format is under development?

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.