في هذه المقالة

How to install Python client libraries for remote access to a Machine Learning Server

06/01/2018

تستغرق القراءة 6 دقائق

المساهمون

في هذه المقالة

Machine Learning Server includes open-source and Microsoft-specific Python packages for modeling, training, and scoring data for statistical and predictive analytics. For classic client-server configurations, where multiple clients connect to and use a remote Machine Learning Server, installing the same Python client libraries on a local workstation enables you to write and run script locally and then push execution to the remote server where data resides. This is referred to as a remote compute context, operant when you call Python functions from libraries that exist on both client and server environments.

This article describes how to install a Python interpreter (Anaconda) and Microsoft's Python packages locally on a client machine. Once installed, you can use all of the Python modules in Anaconda, Microsoft's packages, and any third-party packages that are Python 3.5 compliant. For remote compute context, you can only call the Python functions from packages in the above list.

Check package versions

While not required, it's a good idea to cross-check package versions so that you can match versions on the server with those on the client. On a server with restricted access, you might need an administrator to get this information for you.

Install Python libraries on Windows

Download the installation shell script from https://aka.ms/mls93-py (or use https://aka.ms/mls-py for the 9.2. release). The script installs Anaconda 4.2.0, which includes Python 3.5.2, along with all packages listed previously.

Open PowerShell window with elevated administrator permissions (right-click Run as administrator).

Go to the folder in which you downloaded the installer and run the script. Add the -InstallFolder command-line argument to specify a folder location for the libraries. For example:

Installation takes some time to complete. You can monitor progress in the PowerShell window. When setup is finished, you have a complete set of packages. For example, if you specified C:\mspythonlibs as the folder name, you would find the packages at C:\mspythonlibs\Lib\site-packages.

The installation script does not modify the PATH environment variable on your computer so the new python interpreter and modules you just installed are not automatically available to your tools. For help on linking the Python interpreter and libraries to tools, see Link Python tools and IDEs, replacing the MLS server paths with the path you defined on your workstation For example, for a Python project in Visual Studio, your custom environment would specify C:\mypythonlibs, C:\mypythonlibs\python.exe and C:\mypythonlibs\pythonw.exe for Prefix path, Interpreter path, and Windowed interpreter, respectively.

Offline install

Download .cab files used for offline installation and place them in your %TEMP% directory. You can type %TEMP% in a Run command to get the exact location, but it is usually a user directory such as C:\Users\<your-user-name>\AppData\Local\Temp.

After copying the files, run the PowerShell script using the same syntax as an online install. The script knows to look in the temp directory for the files it needs.

Install Python libraries on Linux

On each supported OS, the package manager downloads packages from the repository, determines dependencies, retrieves additional packages, and installs the software. After installation completes, mlserver-python executable is at '/usr/bin'.

Test local package installation

As a verification step, call functions from the revoscalepy package and from scikit, included in Anaconda.

If you get a "module not found" error for any of the instructions below, verify you are loading the python interpreter from the right location. If using Visual Studio, confirm that you selected the custom environment pointing the prefix and interpreter paths to the correct location.

Note

On Windows, depending on how you run the script, you might see this message: "Express Edition will continue to be enforced". Express edition is one of the free SQL Server editions. This message is telling you that client libraries are licensed under the Express edition. Limits on this edition are the same as Standard: in-memory data sets and 2-core processing. Remote servers typically run higher editions not subjected to the same memory and processing limits. When you push the compute context to a remote server, you work under the full capabilities of that system.

Create some data to work with. This example loads the iris data set using scikit.

Next steps

Now that you have installed local client libraries and verified function calls, try the following walkthroughs to learn how to use the libraries locally and remotely when connected to resident data stores.

Remote access to a SQL Server is enabled by an administrator who has configured ports and protocols, enabled remote connections, and assigned user logins. Check with your administrator to get a valid connection string when using a remote compute context to SQL Server.