Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari iniPelayar ini tidak lagi disokong.
Naik taraf kepada Microsoft Edge untuk memanfaatkan ciri, kemas kini keselamatan dan sokongan teknikal yang terkini.
Applies to:
SQL Server 2022 (16.x) - Linux
This article guides you in the installation of SQL Server Machine Learning Services on Linux. Python and R scripts can be executed in-database using Machine Learning Services.
You can install Machine Learning Services on Ubuntu and Red Hat Enterprise Linux (RHEL). Currently, SUSE Linux Enterprise Server (SLES) is unsupported.
You can install ML Services on a Docker container running a Linux distribution. Inside the Docker container, the steps would be the same as below.
For more information, see the Supported platforms section in the installation guidance for SQL Server on Linux.
Penting
This article refers to SQL Server 2022 (16.x). For SQL Server 2019 on Linux, see to Install SQL Server 2019 Machine Learning Services (Python and R) on Linux. For SQL Server on Windows, see Install SQL Server 2022 Machine Learning Services (Python and R) on Windows.
Install SQL Server on Linux and verify the installation.
Check the SQL Server Linux repositories for the Python and R extensions. If you already configured source repositories for the database engine install, you can run the mssql-server-extensibility package install commands using the same repo registration.
You should have a tool for running T-SQL commands.
Restarting the SQL Server instance during this installation process will be required.
On an internet-connected device, packages are downloaded and installed independently of the database engine using the package installer for each operating system.
Available installation packages for SQL Server 2022 (16.x) on Linux:
Package name | Applies-to | Description |
---|---|---|
mssql-server-extensibility |
All | Extensibility framework used to run Python and R. |
Configure repositories for installing and upgrading SQL Server on Linux corresponding to the Linux distribution. Install the SQL Server extensibility feature with the package mssql-server-extensibility
and associated dependency libssl-dev
.
Ubuntu
sudo apt-get install mssql-server-extensibility libssl-dev
RHEL
yum install mssql-server-extensibility
Review and accept the End User License Agreement (EULA) for SQL Server ML Services.
sudo /opt/mssql/bin/mssql-conf set EULA accepteulaml Y
To complete acceptance of the EULA, the SQL Server instance must be restarted.
sudo systemctl restart mssql-server
Download and install the version of R that is desired. Choose a version of R 4.2 or higher, available for download directly from cran.r-project.org. Follow the instructions for the desired runtime.
Open an admin R terminal:
sudo R
Install dependencies for CompatibilityAPI
and RevoScaleR
by running the following:
# R Terminal
install.packages("iterators", lib="/usr/lib/R/library")
install.packages("foreach", lib="/usr/lib/R/library")
install.packages("R6", lib="/usr/lib/R/library")
install.packages("jsonlite", lib="/usr/lib/R/library")
Download and install CompatibilityAPI
and RevoScaleR
for Linux.
install.packages("https://aka.ms/sqlml/r4.2/linux/CompatibilityAPI_1.1.0_R_x86_64-pc-linux-gnu.tar.gz", repos=NULL, lib="/usr/lib/R/library")
install.packages("https://aka.ms/sqlml/r4.2/linux/RevoScaleR_10.0.1_R_x86_64-pc-linux-gnu.tar.gz", repos=NULL, lib="/usr/lib/R/library")
Verify RevoScaleR
installation from the R terminal.
library("RevoScaleR")
Configure the installed R runtime with SQL Server for Linux, where path/to/
is the file path to the R binary, and RFolderVersion
is the version-specific folder name for your installation of R runtime, for example, R4.2
.
sudo /opt/mssql/bin/mssql-conf set extensibility rbinpath /usr/lib/R/bin/R
sudo /opt/mssql/bin/mssql-conf set extensibility datadirectories /usr/lib/R
Restart the Launchpadd
service.
systemctl restart mssql-launchpadd.service
Configure SQL Server for Linux to allow external scripts using the sp_configure
system stored procedure.
EXECUTE sp_configure 'external scripts enabled', 1;
GO
RECONFIGURE;
GO
Verify the installation by executing a simple T-SQL command to return the version of R:
EXECUTE sp_execute_external_script
@script = N'print(R.version)',
@language = N'R';
GO
Download and install Python. Choose version Python 3.10 specifically, available for download directly from python.org. Follow the instructions provided. Also, install the shared python runtime library for the runtime version. For example, to install libpython3.10
for Ubuntu: sudo apt-get install libpython3.10
.
Download and install revoscalepy
for the root user.
sudo pip install dill numpy==1.22.0 pandas patsy python-dateutil
sudo pip install https://aka.ms/sqlml/python3.10/linux/revoscalepy-10.0.1-py3-none-any.whl --target=/usr/lib/python3.10/dist-packages
Verify the revoscalepy
installation from the Python terminal. Verify the library can be imported.
import revoscalepy
Configure the installed Python runtime with SQL Server, where pythonbinpath
is set to the path of the installed python binary, and datadirectories
includes the path where the packages are installed for the desired version of python, for example, /usr/lib/python3.10/dist-packages
. Use the following script with your actual installation path:
sudo /opt/mssql/bin/mssql-conf set extensibility pythonbinpath /usr/bin/python3.10
sudo /opt/mssql/bin/mssql-conf set extensibility datadirectories /usr/lib:/usr/lib/python3.10/dist-packages
Restart the Launchpadd
service.
systemctl restart mssql-launchpadd.service
Configure SQL Server for Linux to allow external scripts using the sp_configure
system stored procedure.
EXECUTE sp_configure 'external scripts enabled', 1;
GO
RECONFIGURE;
GO
Verify the installation by executing a simple T-SQL command to return the version of python:
EXECUTE sp_execute_external_script
@script = N'import sys;print(sys.version)',
@language = N'Python';
GO
To install the Java language extension, see Install SQL Server Java Language Extension on Linux.
To validate installation, use any of the following methods:
Run a T-SQL script that executes a system stored procedure invoking Python or R using a query tool.
Execute the following SQL command to test R execution in SQL Server. Errors? Try a service restart, sudo systemctl restart mssql-server.service
.
EXECUTE 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.
EXECUTE 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
Follow the Offline installation instructions for steps on installing the packages. Find your download site, and then download specific packages using the package list below.
Tip
Several of the package management tools provide commands that can help you determine package dependencies. For yum, use sudo yum deplist [package]
. For Ubuntu, use sudo apt-get install --reinstall --download-only [package name]
followed by dpkg -I [package name].deb
.
RevoScale packages are also supported as a standalone package with Python and R runtimes. In order to setup Python or R runtime for the standalone scenario, follow the instructions in the Install Python runtime and Install R runtime sections respectively.
Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari iniLatihan
Pensijilan
Microsoft Certified: Azure Data Scientist Associate - Certifications
Manage data ingestion and preparation, model training and deployment, and machine learning solution monitoring with Python, Azure Machine Learning and MLflow.