none
Persistent environment for R in SQL Server 2017 Machine Learning Services RRS feed

  • Question

  • I have configured Machine Learning Services in SQL Server 2017 for my developer to test his R code.

    We haven't found how we can setup a persistent R environment in SQL Server so that the R environment doesn't have to be reloaded every time we run the stored procedure.

    Is there something we missed? Anyone know if this is possible?

    Thanks!

    Steve

    Thursday, April 5, 2018 2:29 PM

All replies

  • I assume you would like to not have to load R packages on startup and would like them to be preloaded.

    If that is what you are after you can modify the file:  

    C:\Program Files\Microsoft\ML Server\R_SERVER\etc\Rprofile.site 

    so that these libraries get automatically loaded on startup.

    You can either add lines like:

    library(data.table)

    to the very end of the file or you can modify the following line to preload these libraries:

    options(defaultPackages=c(getOption("defaultPackages"), "rpart", "lattice", "RevoScaleR",
                if(!identical(system.file(package="mrsdeploy"), "") && identical(.Platform$OS, "windows")) "mrsdeploy",
       # we have MicrosoftML package
       if(!identical(system.file(package="MicrosoftML"),"") && isMMLSupported) "MicrosoftML",
       "RevoMods", "RevoUtils", "RevoUtilsMath"))

    Thursday, April 5, 2018 3:58 PM
  • Sorry, what do you mean by "R environment doesn't have to be reloaded every time we run the stored procedure"?

    In SQL Server, when you execute sp_execute_external_script there is no re-loading of R, not any more than it would be if you run outside of SQL Server in "standard" R environment.


    http://www.nielsberglund.com | @nielsberglund

    Friday, April 6, 2018 4:00 AM
  • I think the question is related to the fact that the R process in SQL Server is recycled after every sp_execute_external_script call, and no R environment is left behind to reuse in future calls. This is by design. If you would like to use long running R sessions, DeployR/Operationalization in ML Server is  designed to do just that: https://docs.microsoft.com/en-us/machine-learning-server/what-is-operationalization . Hope this answers the question?
    • Proposed as answer by renebouw Saturday, April 14, 2018 8:30 PM
    Saturday, April 14, 2018 8:29 PM