Preload packages and models in a session for faster web-service response time RRS feed

  • Question

  • I am in the process of deploying a R script (data transformations + scoring) as a web service in the machine learning server and to cut down on the processing time, I would like to preload the packages, model objects and other config files/ data just once and keep in memory. Is there a way to do it? I read that dedicated session pools can be created but could not find an option to pass an initialization script which will do this work one time.

    Monday, November 5, 2018 2:38 PM

All replies

  • The way to preload libraries is via a user-specific .Rprofile script or via the system-wide file, stored under:

    C:\Program Files\Microsoft\Machine Learning Server\R_SERVER\etc\

    At the end of the file put your library() statements to preload a specific package(s) on the compute nodes.

    You will need to install the libraries on all the compute nodes to begin with.
    For more information on Rprofile see these references:

    Thursday, November 8, 2018 7:19 PM
  • Hi stevefw,

    Is there similar functionality for python? I deployed a web service with python and am importing spacy and loading it's English model with the following 2 lines

    import spacy


    I would like to preload these 2 lines and not have them loaded each time my api gets called. Is there a python script I can modify like If not, how would you recommend I go about doing this?

    Thank you!

    Tuesday, January 15, 2019 3:39 AM
  • MagohA, Please see other thread.
    Wednesday, January 16, 2019 12:53 AM
  • How to make it specific to a web service than a user? For example, I may have two different web services each of which requires a different set of libraries and base data which if remains loaded in the RAM, can reduce the processing time significantly.
    Saturday, February 9, 2019 2:10 PM