azure 机器学习和 R 使用 azuremlsdk - 支持的 R 版本和 custom_docker_image

问题描述

因此我们必须放弃使用 SQL Server Machine Learning services,因为它即使对于 sql Server 2019 也仅支持 R 3.5.2!

我正在努力进入整个 21 世纪,并将我们的一些本地 R 训练模型部署为网络服务,如 Microsoft evangelists David Smith 中的一个(请参阅下面的代码)所述。

看着 r_environment 我惊恐地注意到,如果我不使用自定义 docker 映像,预定义映像仅支持 R 3.6?!这样对吗?如果是这样,我如何创建自定义 docker 映像以及为什么 Microsoft 建议使用 Azure ML,其中 R 版本也有限制!

附注:

一些可能会复制我的问题的代码

在本地训练模型:

library(datasets)
library(caret)

data(iris)

setwd("C:/Data")

index <- createDataPartition(iris$Species,p=0.80,list=FALSE)
testset <- iris[-index,]
trainset <- iris[index,]

model = train(Species ~ .,data=trainset,method="rpart",trControl = trainControl(method = "cv"))

saveRDS(model,"model.rds")

我可以在 Azure ML 中部署这个模型:

enter image description here

评分脚本 score.r

library(jsonlite)

init <- function()
{
  model_path <- Sys.getenv("AZUREML_MODEL_DIR")
  model <- readRDS(file.path(model_path,"model.rds"))
  message("iris classfication model loaded")
  
  function(data)
  {
    vars <- as.data.frame(fromJSON(data))
    prediction <- predict(model,newdata=vars)
    toJSON(prediction)
  }
}

失败代码

library(azuremlsdk)

interactive_auth <- interactive_login_authentication(tenant_id="xxx")

ws <- get_workspace(
        name = "amazing_work_space",subscription_id = "xxx",resource_group ="xxx",auth = interactive_auth
)

model <- get_model(ws,name = "iris_classification")

r_env <- r_environment(name = 'myr_env',version = '1')

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,'xxx',list(model),inference_config,aci_config)

wait_for_deployment(aci_service,show_output = TRUE)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)