All Products
Search
Document Center

Platform For AI:Install and configure PAI SDK for Python

Last Updated:Nov 12, 2024

PAI SDK for Python provides easy-to-use high-level APIs and enables Artificial Intelligence (AI) and machine learning engineers to train and deploy models in Platform for AI (PAI) in an efficient manner. PAI SDK for Python is used in the entire AI and machine learning process.

Prerequisites

  • An AccessKey pair is obtained. For more information, see Obtain an AccessKey pair.

  • A workspace is created. For more information, see Create a workspace.

  • An OSS bucket is created. For more information, see Get started by using the OSS console.

  • Python 3.7 or later is prepared.

  • If you use the SDK as a RAM user, make sure that you have related permissions on the workspace and Object Storage Service (OSS) buckets.

    • To submit a training job in a workspace, a RAM user must be assigned a developer or administrator role of the workspace. For information about how to manage workspace members, see Manage members of the workspace.

    • To store assets such as code and models in OSS buckets, a RAM user must have read and write permissions on the OSS buckets. For more information, see the "Grant your RAM user or RAM role the permissions to access OSS" section in the Grant the permissions that are required to use Machine Learning Designer topic.

Install PAI SDK for Python

Run the following command to install PAI SDK for Python. Make sure that your Python is of 3.7 or later.

pip install "alipai>=0.4.0"

Initialize the SDK

Run the following command on your CLI and perform the following operations to configure the required parameters:

# Run the following command in the CLI after the SDK is installed. 
python -m pai.toolkit.config

The following figure shows an example of running the python -m pai.toolkit.config command to grant permissions.

image..png

If an output similar to Configuration saved successfully: <Path to which the configurations are saved> is displayed, the configuration is complete.

References

After you initialize the SDK, you can train models. For more information, see Submit training jobs.