WPB
WPB

Reputation: 53

How to install R packages into Azure Machine Learning

I have trained a model locally using the R package locfit. I am now trying to run this in Azure Machine Learning.

Most guides/previous questions appear to be in relation to Azure Machine Learning (classic). Although I believe the process outlined in similar posts will be similar (e.g. here, here, I am still unable to get it to work.

I have outlined the steps I have followed below:

  1. Download locfit R package for windows Zip file from here

  2. Put this downloaded Zip file into a new Zip file entitled "locfit_package"

  3. I upload this "locfit_package" zip folder to AML as a dataset (Create Dataset > From Local Files > name: locfit_package dataset type: file > Upload the zip ("locfit_package") > Confirm upload is correct

  4. In the R terminal I then execute the following code:

    install.packages("src/locfit_package.zip", lib = ".", repos = NULL, verbose = TRUE)

    library(locfit_package, lib.loc=".", verbose=TRUE)

    library(locfit)

  5. The following error message is then returned:

    system (cmd0): /usr/lib/R/bin/R CMD INSTALL

    Warning: invalid package ‘src/locfit_package.zip’ Error: ERROR: no packages specified Warning message:

    In install.packages("src/locfit_package.zip", lib = ".", repos = NULL, : installation of package ‘src/locfit_package.zip’ had non-zero exit status Error in library(locfit_package, lib.loc = ".", verbose = TRUE) : there is no package called ‘locfit_package’ Execution halted

Upvotes: 1

Views: 970

Answers (1)

Yutong Tie
Yutong Tie

Reputation: 498

I just checked on the document, it says:"Excute R Script module does not support installing packages that require native compilation, like qdap package which requires JAVA and drc package which requires C++. This is because this module is executed in a pre-installed environment with non-admin permission. Do not install packages which are pre-built on/for Windows, since the designer modules are running on Ubuntu. To check whether a package is pre-built on windows, you could go to CRAN and search your package, download one binary file according to your OS, and check Built: part in the DESCRIPTION file. Following is an example: enter image description here

And the sample code:

    # R version: 3.5.1
# The script MUST contain a function named azureml_main,
# which is the entry point for this module.

# Note that functions dependent on the X11 library,
# such as "View," are not supported because the X11 library
# is not preinstalled.

# The entry point function MUST have two input arguments.
# If the input port is not connected, the corresponding
# dataframe argument will be null.
#   Param<dataframe1>: a R DataFrame
#   Param<dataframe2>: a R DataFrame
azureml_main <- function(dataframe1, dataframe2){
  print("R script run.")
  
  if(!require(zoo)) install.packages("zoo",repos = "https://cloud.r-project.org")
  library(zoo)
  # Return datasets as a Named List
  return(list(dataset1=dataframe1, dataset2=dataframe2))
}

Could you please check on if your package is on this? Reference document: https://learn.microsoft.com/en-us/azure/machine-learning/algorithm-module-reference/execute-r-script

Upvotes: 0

Related Questions