Quick Start
Introduction
Xiaomi Cloud-ML provides a deep-learning platform service. Users only need to write model code for the TensorFlow app and submit it to cloud training. It can then start the model service for predicting.
Install Client
Refer to Install command line tool to initialize the client-side runtime environment.
Configuring Clients
Users need Access key and Secret key of Eco Cloud to initialize, with the following command:
cloudml init
User configuration is automatically saved to the ~/.config/xiaomi/config
file, or AKSK is initialized by means of environment variables.
export XIAOMI_ACCESS_KEY_ID="AKPFUTXXXXXXLIPXVG"
export XIAOMI_SECRET_ACCESS_KEY="JDv8ER5CocaISnLXXXXXXXXXXaXfyOpjz8nrLsuB"
export XIAOMI_CLOUDML_ENDPOINT="https://cnbj3-cloud-ml.api.xiaomi.net"
Note: XIAOMI_CLOUDML_ENDPOINT
needs to be configured differently depending on the cluster. Please refer to "Cluster Environment".
Writing Model Code
Users can write Cloud-ML model code that is compatible with the community version of TensorFlow, which can be packaged using standard Python modules.
We also provide examples from sample projects. Please refer to https://github.com/XiaoMi/cloud-ml-sdk.
The following is an example from a linear model project that can be tested and submitted directly by running the following command.
mkdir trainer
touch trainer/__init__.py
curl "https://raw.githubusercontent.com/XiaoMi/cloud-ml-sdk/master/cloud_ml_samples/tensorflow/linear_regression/trainer/task.py" > trainer/task.py
Then test and verify the capabilities of the TensorFlow application locally. Please note that Xiaomi Cloud-ML supports the standard TensorFlow application. Locally-executable code can also be run in the cloud. It must be tested locally and pass before submission.
python -m trainer.task
Packaging Model Code
We then package this Python module and save it as a tar.gz file.
cat << EOF > setup.py
import setuptools
setuptools.setup(name='trainer', version='1.0', packages=['trainer'])
EOF
python setup.py sdist --format=gztar
Then upload the model code to the FDS service. You can use the Eco Cloud console or the FDS command line tool for this task.
FDS Path Format
The format of the file path for uploading files to fds is fds://{bucket_name}/path/to/file
.
For example, if the user's bucket name is cloud-ml and the data is placed under the Test/readme path of the bucket, then the FDS file path format will be:
fds://cloud-ml/test/README
Submit Training Tasks
Use the following command to submit a training task, assuming that the bucket created by the user is cloud-ml
and the model code is uploaded to the path of fds://cloud-ml/linear/trainer-1.0.tar.gz
.
cloudml jobs submit -n linear -m trainer.task -u fds://cloud-ml/linear/trainer-1.0.tar.gz -a "--model_path fds://cloud-ml/linear_model --output_path fds://cloud-ml/linear_tensorboard"
When submitting a task, specify model_path
to indicate the exported path of the model, and specify output_path
to indicate the path of the exported TensorBoard file. This must be an Fds path the user has permission to read and write.
After submitting the task, we can view the status and log of the training task through the command line tool.
cloudml jobs list
cloudml jobs logs linear