Skip to content

Latest commit

 

History

History
220 lines (152 loc) · 7.5 KB

File metadata and controls

220 lines (152 loc) · 7.5 KB
title Install SQL Server Machine Learning Services (R, Python, Java) on Linux | Microsoft Docs
description This article describes how to install SQL Server Machine Learning Services (R, Python, Java) on Red Hat and Ubuntu.
author HeidiSteen
ms.author heidist
manager cgronlun
ms.date 09/09/2018
ms.topic conceptual
ms.prod sql
ms.component
ms.suite sql
ms.custom sql-linux
ms.technology machine-learning
monikerRange >=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions

Install SQL Server 2019 Machine Learning Services (R, Python, Java) on Linux

SQL Server Machine Learning Services runs on Linux operating systems starting in this CTP 2.0 release of SQL Server 2019. Follow these steps to install the Java programming extension, or the machine learning extensions for R and Python.

Prerequisites

Note

SUSE (SLES) is not a supported operating system for Java, R, or Python extensions in this release.

After the database engine is installed and configured, you can add the programming language extensions for Java, R, or Python. Packages for these extensions are downloaded and installed independently of the database engine. Download links and nstructions for each operating system are provided in the following sections.

Red Hat package install

Run the following commands to install SQL Server with Machine Learning Services with both R and Python.

# sudo yum install mssql-mlservices-all-9.4.1   

Add R only

Run the following commands to install SQL Server with Machine Learning Services with only R.

# sudo yum install mssql-mlservices-R-9.4.1   

Add Python only

Run the following commands to install SQL Server with Machine Learning Services with only Python.

# sudo yum install mssql-mlservices-python-9.4.1   

Ubuntu package install

Run the following commands to install SQL Server with Machine Learning Services with both R and Python:

# sudo apt-get install mssql-mlservices-all-9.4.1   

Add R only

Run the following commands to install SQL Server with Machine Learning Services with only R:

# sudo apt-get install mssql-mlservices-R-9.4.1   

Add Python only

Run the following commands to install SQL Server with Machine Learning Services with only Python:

# sudo apt-get install mssql-mlservices-python-9.4.1   

Unattended installation

For open-source R and Python components, use the environment variable (ACCEPT_ML_EULA) to accept the ML Services EULA supplement for unattended installations. This is a supplement to the SQL Server EULA.

The following example configures the Developer edition of SQL Server with SQL Server Machine Learning Services. The -n parameter performs an unprompted installation where the configuration values are pulled from the environment variables.

sudo MSSQL_PID=Developer ACCEPT_EULA=Y ACCEPT_ML_EULA=Y SSQL_SA_PASSWORD='<YourStrong!Passw0rd>' /opt/mssql/bin/mssql-conf -n setup 

For more information, see Unattended install.

Offline installation

  1. Locate the MLS-specific package downloads in the Release notes.

  2. Continue with Offline installation instructions for your next step.

Post-install configuration

After the database engine and Machine Learning Services packages are installed, configure the server for operations. This task includes acceptance of SQL Server, R, and Python license agreements and provision of the system administrator (SA) password.

Run the configuration script to accept the license agreement and provide the System Administrator (SA) password:

$ sudo /opt/mssql/bin/mssql-conf setup 

If you already have a SQL Server installation and just want to add the feature machine learning services, then you can install mlservices packages and run the following to accept the mlservices EULA:

$ sudo /opt/mssql/bin/mssql-conf set accept-eula ml 

Configure external script execution

Before running R and Python scripts in SQL Server, enable external script execution:

EXEC sp_configure 'external scripts enabled', 1 
RECONFIGURE WITH OVERRIDE 

Restart SQL Server for the changes to take effect:

# sudo systemctl restart mssql-server 

Verify external script execution

  Execute the following SQL command to test R execution in SQL Server:

EXEC sp_execute_external_script   
@language =N'R', 
@script=N' 
OutputDataSet <- InputDataSet', 
@input_data_1 =N'SELECT 1 AS hello' 
WITH RESULT SETS (([hello] int not null)); 
GO 

Execute the following SQL command to test Python execution in SQL Server:

EXEC sp_execute_external_script  
@language =N'Python', 
@script=N' 
OutputDataSet = InputDataSet; 
', 
@input_data_1 =N'SELECT 1 AS hello' 
WITH RESULT SETS (([hello] int not null)); 
GO 

Add other R and Python packages

You can install other R and Python packages and use them in script that executes on SQL Server 2019.

R packages

  1. Start an R session.

    # sudo /opt/mssql/mlservices/bin/R/R 
  2. Install an R package called “glue” to test package installation.

    # install.packages("glue",lib="/opt/mssql/mlservices/libraries/RServer") 

    Alternatively, you can install an R package from the command line

    # sudo /opt/mssql/mlservices/bin/R/R CMD INSTALL -l /opt/mssql/mlservices/libraries/RServer glue_1.1.1.tar.gz 

  3. Import the R package in sp_execute_external_script

EXEC sp_execute_external_script  
@language = N'R', 
@script = N'library(glue)' 

Python packages

  1. Install a Python package called “httpie” using pip.

    # sudo /opt/mssql/mlservices/bin/python/python -m pip install httpie 

   
2. Import the Python package in sp_execute_external_script

EXEC sp_execute_external_script  
@language = N'Python',  
@script = N'import httpie' 

Limitations in CTP 2.0

The following limitations exist in this CTP release.

  • Implied authentication currently not available in Machine Learning Services on Linux, which means connecting back to the server from within an R or Python script is not supported on Linux at this time.

Next steps

R developers can get started with some simple examples, and learn the basics of how R works with SQL Server. For your next step, see the following links:

Python developers can learn how to use Python with SQL Server by following these tutorials:

To view examples of machine learning that are based on real-world scenarios, see Machine learning tutorials.