我正在尝试按照这篇文章在 Azure 中部署“模型”。
代码片段如下,模型,它只是一个添加 2 个数字的函数,似乎注册得很好。在 1000 次尝试后,我什至不使用该模型来隔离问题,因为此评分代码显示:
library(jsonlite)
init <- function()
{
message("hello world")
function(data)
{
vars <- as.data.frame(fromJSON(data))
prediction <- 2
toJSON(prediction)
}
}
应该没问题吧?我以任何方式运行此代码段:
r_env <- r_environment(name = "basic_env")
inference_config <- inference_config(
entry_script = "score.R",
source_directory = ".",
environment = r_env)
aci_config <- aci_webservice_deployment_config(cpu_cores = 1, memory_gb = 0.5)
aci_service <- deploy_model(ws,
'xxxxx',
list(model),
inference_config,
aci_config)
wait_for_deployment(aci_service, show_output = TRUE)
这会产生这个(经过很长时间):
Running.....................................................................
Failed
Service deployment polling reached non-successful terminal state, current service state: Failed
Operation ID: 14c35064-7ff4-46aa-9bfa-ab8a63218a2c
More information can be found using '.get_logs()'
Error:
{
"code": "AciDeploymentFailed",
"statusCode": 400,
"message": "Aci Deployment failed with exception: Error in entry script, RuntimeError: Error in file(filename, \"r\", encoding = encoding) : , please run print(service.get_logs()) to get details.",
"details": [
{
"code": "CrashLoopBackOff",
"message": "Error in entry script, RuntimeError: Error in file(filename, \"r\", encoding = encoding) : , please run print(service.get_logs()) to get details."
}
]
}
它并没有告诉我太多。不确定如何进一步调试?我该如何运行:
print(service.get_logs())
请问在哪里?猜猜这是一个 Python 神器?非常欢迎任何其他输入。
PS:
在这个时间点,我怀疑上面的 R 入口文件定义不是这些天所期望的。查看从此处获取的 Python 等效项:
import json
def init():
print("This is init")
def run(data):
test = json.loads(data)
print(f"received data {test}")
return f"test is {test}"
这样的事情会不会更合适(尝试过但没有成功)。
library(jsonlite)
init <- function()
{
message("hello world")
}
init <- function()
{
return(42)
}