如何使用Docker在R中正确安装mlflow?

nnsrf1az  于 2023-06-19  发布在  Docker
关注(0)|答案(1)|浏览(154)

在docker中安装mlflow和R有什么标准的镜像或步骤吗?
每当我这样做,有时它的 *CURL找不到问题 依赖项未安装正确 *.. https://mdneuzerling.com/post/deploying-r-models-with-mlflow-and-docker/执行此操作并失败。

Warning messages:
1: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘curl’ had non-zero exit status
2: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘RCurl’ had non-zero exit status
3: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘httr’ had non-zero exit status
4: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘h2o’ had non-zero exit status
5: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘covr’ had non-zero exit status
6: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘sparklyr’ had non-zero exit status
7: In install.packages("mlflow", dependencies = TRUE) :
  installation of package ‘mlflow’ had non-zero exit status
kmpatx3s

kmpatx3s1#

有一个R API:https://mlflow.org/docs/latest/R-api.html#r-api。对于非常基本的设置,您可以使用此Dockerfile:

FROM rocker/tidyverse

# Install python
RUN apt-get update -qq && \
 apt-get install -y python3-pip tcl tk libz-dev libpng-dev

RUN ln -f /usr/bin/python3 /usr/bin/python
RUN ln -f /usr/bin/pip3 /usr/bin/pip
RUN pip install -U pip

# Install mlflow
RUN pip install mlflow

# Create link for python
RUN ln -f /usr/bin/python3 /usr/bin/python

# Install additional R packages
RUN R -e "devtools::install_github('mlflow/mlflow', subdir = 'mlflow/R/mlflow')"
RUN R -e "install.packages(c('carrier'))" # for crating
# any other packages Your R project requires
# RUN R -e "install.packages(...)"

在R脚本中:

library(mlflow)

# ... some R code

with(run <- mlflow_start_run(), {
  print("building model...\n")
  ctrl <- rpart.control(cp = 0.1)
  model <- rpart(Species ~ ., data = iris, method = "class", control = ctrl)

  predictor <- crate(~ stats::predict(!!model, .x, type = "class"))
  predicted <- predictor(iris)

  print("logging model...\n")
  mlflow_log_model(predictor, "model")
})

这只是一个草稿。您提供的链接是一个更真实的场景。把我的答案当作一个玩具,但也许它可以帮助你潜入更复杂的问题。我认为你需要了解更多关于Docker和Linux的基础知识,才能让R和mlflow在容器中一起工作。您得到的错误很可能与系统中丢失的包有关(在Docker中)。注意你的基本形象。
希望能有所帮助。

相关问题