Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Object Storage
    • All tutorials
    • Getting statistics on object queries with S3 Select
    • Getting website traffic statistics with S3 Select
    • Getting statistics on object queries using Yandex Query
    • Generating a resource-by-resource cost breakdown report using S3 Select
    • Server-side encryption
    • Integrating an L7 load balancer with CDN and Object Storage
    • Blue-green and canary deployment of service versions
    • Analyzing logs in DataLens
    • Mounting buckets to the file system of Yandex Data Processing hosts
    • Using Object Storage in Yandex Data Processing
    • Importing data from Object Storage, processing and exporting to Managed Service for ClickHouse®
    • Mounting a bucket as a disk in Windows
    • Migrating data from Yandex Data Streams using Yandex Data Transfer
    • Using hybrid storage in Yandex Managed Service for ClickHouse®
    • Loading data from Yandex Managed Service for OpenSearch to Yandex Object Storage using Yandex Data Transfer
    • Automatically copying objects from one bucket to another
    • Recognizing audio files in a bucket on a regular basis
    • Training a model in Yandex DataSphere on data from Object Storage
    • Connecting to Object Storage from VPC
    • Migrating data to Yandex Managed Service for PostgreSQL using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for Greenplum® using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for ClickHouse® using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for YDB using Yandex Data Transfer
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Uploading data from Yandex Managed Service for YDB using Yandex Data Transfer
    • Hosting a static Gatsby website in Object Storage
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Importing data from Yandex Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Importing data from Yandex Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Migrating data from Yandex Object Storage to Yandex Managed Service for MySQL® using Yandex Data Transfer
    • Migrating a database from Yandex Managed Service for MySQL® to Yandex Object Storage
    • Exporting Greenplum® data to a cold storage in Yandex Object Storage
    • Loading data from Yandex Direct to a Yandex Managed Service for ClickHouse® data mart using Yandex Cloud Functions, Yandex Object Storage, and Yandex Data Transfer
    • Migrating data from Elasticsearch to Yandex Managed Service for OpenSearch
    • Uploading Terraform states to Object Storage
    • Locking Terraform states using Managed Service for YDB
    • Visualizing Yandex Query data
    • Publishing game updates
    • VM backups using Hystax Acura
    • Backing up to Object Storage with CloudBerry Desktop Backup
    • Backing up to Object Storage with Duplicati
    • Backing up to Object Storage with Bacula
    • Backing up to Yandex Object Storage with Veeam Backup
    • Backing up to Object Storage with Veritas Backup Exec
    • Managed Service for Kubernetes cluster backups in Object Storage
    • Developing a custom integration in API Gateway
    • URL shortener
    • Storing application runtime logs
    • Developing a skill for Alice and a website with authorization
    • Creating an interactive serverless application using WebSocket
    • Deploying a web application using the Java Servlet API
    • Developing a Telegram bot
    • Replicating logs to Object Storage using Fluent Bit
    • Replicating logs to Object Storage using Data Streams
    • Uploading audit logs to ArcSight SIEM
    • Exporting audit logs to SIEM Splunk systems
    • Creating an MLFlow server for logging experiments and artifacts
    • Operations with data using Yandex Query
    • Federated data queries using Query
    • Recognizing text in image archives using Vision OCR
    • Converting a video to a GIF in Python
    • Automating tasks using Managed Service for Apache Airflow™
    • Processing files with usage details in Yandex Cloud Billing
    • Deploying a web app with JWT authorization in API Gateway and authentication in Firebase
    • Searching for Yandex Cloud events in Yandex Query
    • Searching for Yandex Cloud events in Object Storage
    • Creating an external table from a bucket table using a configuration file
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Required paid resources
  • Set up your infrastructure
  • Create a folder
  • Create a service account for Object Storage
  • Create a static access key
  • Create an SSH key pair
  • Create a VM
  • Create a managed DB
  • Create a bucket
  • Install the MLFlow tracking server and add it to the VM auto-start
  • Enable MLFlow autorun
  • Create secrets
  • Train your model
  • How to delete the resources you created
  1. Tutorials
  2. Creating an MLFlow server for logging experiments and artifacts

Creating an MLFlow server for logging experiments and artifacts

Written by
Yandex Cloud
Improved by
Egor K.
Updated at May 7, 2025
  • Getting started
    • Required paid resources
  • Set up your infrastructure
    • Create a folder
    • Create a service account for Object Storage
  • Create a static access key
  • Create an SSH key pair
  • Create a VM
  • Create a managed DB
  • Create a bucket
  • Install the MLFlow tracking server and add it to the VM auto-start
    • Enable MLFlow autorun
  • Create secrets
  • Train your model
  • How to delete the resources you created

This tutorial describes how to deploy an MLFlow tracking server for logging experiments and artifacts on a separate Yandex Compute Cloud VM. We will run experiments in JupyterLab Notebook. We will use a Yandex Managed Service for PostgreSQL database to store internal objects and a Yandex Object Storage bucket to store artifacts.

To create an MLFlow server for logging JupyterLab Notebook experiments and artifacts:

  1. Set up your infrastructure.
  2. Create a static access key.
  3. Create an SSH key pair.
  4. Create a VM.
  5. Create a managed DB.
  6. Create a bucket.
  7. Install the MLFlow tracking server and add it to the VM auto-start.
  8. Create secrets.
  9. Train your model.

If you no longer need the resources you created, delete them.

Getting startedGetting started

Before getting started, register in Yandex Cloud, set up a community, and link your billing account to it.

  1. On the DataSphere home page, click Try for free and select an account to log in with: Yandex ID or your working account with the identity federation (SSO).
  2. Select the Yandex Cloud Organization organization you are going to use in Yandex Cloud.
  3. Create a community.
  4. Link your billing account to the DataSphere community you are going to work in. Make sure you have a linked billing account and its status is ACTIVE or TRIAL_ACTIVE. If you do not have a billing account yet, create one in the DataSphere interface.

Required paid resourcesRequired paid resources

The cost of training a model based on Object Storage data includes:

  • Fee for using DataSphere computing resources.
  • Fee for using Compute Cloud computing resources.
  • Fee for a running Managed Service for PostgreSQL cluster.
  • Fee for storing data in a bucket (see Object Storage pricing).
  • Fee for data operations (see Object Storage pricing).

Set up your infrastructureSet up your infrastructure

Log in to the Yandex Cloud management console and select the organization you use to access DataSphere. On the Yandex Cloud Billing page, make sure you have a billing account linked.

If you have an active billing account, you can create or select a folder to deploy your infrastructure in, on the cloud page.

Note

If you use an identity federation to access Yandex Cloud, billing details might be unavailable to you. In this case, contact your Yandex Cloud organization administrator.

Create a folderCreate a folder

Management console
  1. In the management console, select a cloud and click Create folder.
  2. Give your folder a name, e.g., data-folder.
  3. Click Create.

Create a service account for Object StorageCreate a service account for Object Storage

To access a bucket in Object Storage, you will need a service account with the storage.viewer and storage.uploader roles.

Management console
  1. In the management console, navigate to data-folder.
  2. From the list of services, select Identity and Access Management.
  3. Click Create service account.
  4. Enter a name for the service account, e.g., datasphere-sa.
  5. Click Add role and assign the storage.viewer and storage.uploader roles to the service account.
  6. Click Create.

Create a static access keyCreate a static access key

To access Object Storage from DataSphere, you will need a static key.

Management console
CLI
API
  1. In the management console, navigate to the folder the service account belongs to.
  2. From the list of services, select Identity and Access Management.
  3. In the left-hand panel, select Service accounts.
  4. In the list that opens, select the datasphere-sa service account.
  5. In the top panel, click Create new key.
  6. Select Create static access key.
  7. Specify the key description and click Create.
  8. Save the ID and secret key. After you close this dialog, the key value will not be shown again.
  1. Create an access key for the datasphere-sa service account.

    yc iam access-key create --service-account-name datasphere-sa
    

    Result:

    access_key:
      id: aje6t3vsbj8l********
      service_account_id: ajepg0mjt06s********
      created_at: "2022-07-18T14:37:51Z"
      key_id: 0n8X6WY6S24N7Oj*****
    secret: JyTRFdqw8t1kh2-OJNz4JX5ZTz9Dj1rI9hx*****
    
  2. Save the ID (key_id) and secret key (secret). You will not be able to get the secret key again.

To create an access key, use the create method for the AccessKey resource.

Create an SSH key pairCreate an SSH key pair

To connect to a VM over SSH, you will need a key pair: the public key resides on the VM, and the private one is kept by the user. This method is more secure than login and password authentication.

Note

SSH connections using a login and password are disabled by default on public Linux images that are provided by Yandex Cloud.

To create a key pair:

Linux/macOS
Windows 10/11
Windows 7/8
  1. Open the terminal.

  2. Use the ssh-keygen command to create a new key:

    ssh-keygen -t ed25519 -C "<optional_comment>"
    

    You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

    After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

    By default, the command prompts you to save the key under the id_ed25519 name in the following directory: /home/<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

If you do not have OpenSSH installed yet, follow this guide to install it.

  1. Run cmd.exe or powershell.exe (make sure to update PowerShell before doing so).

  2. Use the ssh-keygen command to create a new key:

    ssh-keygen -t ed25519 -C "<optional_comment>"
    

    You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

    After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

    By default, the command prompts you to save the key under the id_ed25519 name in the following folder: C:\Users\<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

Create keys using the PuTTY app:

  1. Download and install PuTTY.

  2. Add the folder with PuTTY to the PATH variable:

    1. Click Start and type Change system environment variables in the Windows search bar.
    2. Click Environment Variables... at the bottom right.
    3. In the window that opens, find the PATH parameter and click Edit.
    4. Add your folder path to the list.
    5. Click OK.
  3. Launch the PuTTYgen app.

  4. Select EdDSA as the pair type to generate. Click Generate and move the cursor in the field above it until key creation is complete.

    ssh_generate_key

  5. In Key passphrase, enter a strong password. Enter it again in the field below.

  6. Click Save private key and save the private key. Do not share its key phrase with anyone.

  7. Click Save public key and save the public key to a file named <key_name>.pub.

Create a VMCreate a VM

Management console
  1. On the folder dashboard of the management console, click Create resource and select Virtual machine instance.

  2. Under Boot disk image, in the Product search field, enter Ubuntu 22.04 and select a public Ubuntu 22.04 image.

  3. Under Location, select the ru-central1-a availability zone.

  4. Under Disks and file storages, select the SSD disk type and specify its size: 20 GB.

  5. Under Computing resources, navigate to the Custom tab and specify the required platform, number of vCPUs, and the amount of RAM:

    • Platform: Intel Ice Lake
    • vCPU: 2
    • Guaranteed vCPU performance: 100%
    • RAM: 4 GB
  6. Under Network settings:

    • In the Subnet field, select the subnet specified in the DataSphere project settings. Make sure the subnet has a configured NAT gateway.
    • Under Public IP address, leave Auto to assign a random external IP address from the Yandex Cloud pool to your VM. Alternatively, select a static address from the list if you reserved one.
  7. Under Access, select SSH key and specify the VM access credentials:

    • Under Login, enter a username. Do not use root or other reserved usernames. To perform operations requiring root privileges, use the sudo command.
    • In the SSH key field, select the SSH key saved in your organization user profile.

      If there are no saved SSH keys in your profile, or you want to add a new key:

      • Click Add key.
      • Enter a name for the SSH key.
      • Upload or paste the contents of the public key file. You need to create a key pair for the SSH connection to a VM yourself.
      • Click Add.

      The SSH key will be added to your organization user profile.

      If users cannot add SSH keys to their profiles in the organization, the added public SSH key will only be saved to the user profile of the VM being created.

  8. Under General information, specify the VM name: mlflow-vm.

  9. Under Additional, select the datasphere-sa service account.

  10. Click Create VM.

Create a managed DBCreate a managed DB

Management console
  1. In the management console, select the folder where you want to create a DB cluster.
  2. Select Managed Service for PostgreSQL.
  3. Click Create cluster.
  4. Enter a name for the cluster, e.g., mlflow-bd.
  5. Under Host class, select the s3-c2-m8 configuration.
  6. Under Size of storage, select 250 GB.
  7. Under Database, enter your username and password. You will need these to establish a connection.
  8. Under Hosts, select the ru-central1-a availability zone.
  9. Click Create cluster.
  10. Go to the DB you created and click Connect.
  11. Save the host link from the host field: you will need it to establish a connection.

Create a bucketCreate a bucket

Management console
  1. In the management console, select the folder where you want to create a bucket.
  2. From the list of services, select Object Storage.
  3. At the top right, click Create bucket.
  4. In the ** Name** field, enter a name for the bucket, e.g., mlflow-bucket.
  5. In the Object read access, Object listing access, and Read access to settings fields, select Restricted.
  6. Click Create bucket.
  7. To create a folder for MLflow artifacts, open the bucket you created and click Create folder.
  8. Enter a name for the folder, e.g., artifacts.

Install the MLFlow tracking server and add it to the VM auto-startInstall the MLFlow tracking server and add it to the VM auto-start

  1. Connect to the VM over SSH.

  2. Download the Anaconda distribution:

    curl --remote-name https://repo.anaconda.com/archive/Anaconda3-2023.07-1-Linux-x86_64.sh
    
  3. Run its installation:

    bash Anaconda3-2023.07-1-Linux-x86_64.sh
    

    Wait for the installation to complete and restart the shell.

  4. Create an environment:

    conda create -n mlflow
    
  5. Activate the environment:

    conda activate mlflow
    
  6. Install the required packages by running these commands one by one:

    conda install -c conda-forge mlflow
    conda install -c anaconda boto3
    pip install psycopg2-binary
    pip install pandas
    
  7. Create the environment variables for S3 access:

    • Open the file with the variables:

      sudo nano /etc/environment
      
    • Add these lines to the file while substituting the placeholders with your VM's internal IP address:

      MLFLOW_S3_ENDPOINT_URL=https://storage.yandexcloud.net/
      MLFLOW_TRACKING_URI=http://<VM_internal_IP_address>:8000
      
  8. Specify the data for the boto3 library to access S3:

    • Create the .aws folder:

      mkdir ~/.aws
      
    • Create the credentials file:

      nano ~/.aws/credentials
      
    • Add these lines to the file while substituting the placeholders with the static key ID and value:

      [default]
      aws_access_key_id=<static_key_ID>
      aws_secret_access_key=<secret_key>
      
  9. Run the MLFlow tracking server while substituting the placehoders with your cluster data:

    mlflow server --backend-store-uri postgresql://<username>:<password>@<host>:6432/db1?sslmode=verify-full --default-artifact-root s3://mlflow-bucket/artifacts -h 0.0.0.0 -p 8000
    

    You can check your connection to MLFlow at http://<VM_public_IP_address>:8000.

Enable MLFlow autorunEnable MLFlow autorun

For MLFlow to run automatically after the VM restarts, you need to convert it into a Systemd service.

  1. Create directories for storing logs and error details:

    mkdir ~/mlflow_logs/
    mkdir ~/mlflow_errors/
    
  2. Create the mlflow-tracking.service file:

    sudo nano /etc/systemd/system/mlflow-tracking.service
    
  3. Add these lines to the file while substituting the placeholders with your data:

    [Unit]
    Description=MLflow Tracking Server
    After=network.target
    
    [Service]
    Environment=MLFLOW_S3_ENDPOINT_URL=https://storage.yandexcloud.net/
    Restart=on-failure
    RestartSec=30
    StandardOutput=file:/home/<VM_username>/mlflow_logs/stdout.log
    StandardError=file:/home/<VM_username>/mlflow_errors/stderr.log
    User=<VM_username>
    ExecStart=/bin/bash -c 'PATH=/home/<VM_username>/anaconda3/envs/mlflow_env/bin/:$PATH exec mlflow server --backend-store-uri postgresql://<DB_username>:<password>@<host>:6432/db1?sslmode=verify-full --default-artifact-root s3://mlflow-bucket/artifacts -h 0.0.0.0 -p 8000'
    
    [Install]
    WantedBy=multi-user.target
    

    Where:

    • <VM_username>: VM account username.
    • <DB_username>: Username specified when creating the database cluster.
  4. Run the service and enable autoload at system startup:

    sudo systemctl daemon-reload
    sudo systemctl enable mlflow-tracking
    sudo systemctl start mlflow-tracking
    sudo systemctl status mlflow-tracking
    

Create secretsCreate secrets

  1. Select the relevant project in your community or on the DataSphere homepage in the Recent projects tab.

  2. Under Project resources, click Secret.
  3. Click Create.
  4. In the Name field, enter the name for the secret: MLFLOW_S3_ENDPOINT_URL.
  5. In the Value field, paste the URL: https://storage.yandexcloud.net/.
  6. Click Create.
  7. Create three more secrets:
    • MLFLOW_TRACKING_URI with the http://<VM_internal_IP_address>:8000 value.
    • AWS_ACCESS_KEY_ID with the static key ID.
    • AWS_SECRET_ACCESS_KEY with the static key value.

Train your modelTrain your model

This tutorial features a set of data for predicting the quality of wine based on quantitative properties, such as acidity, PH, residual sugar, etc. To train your model, copy and paste the code into the notebook cells.

  1. Open the DataSphere project:

    1. Select the relevant project in your community or on the DataSphere homepage in the Recent projects tab.

    2. Click Open project in JupyterLab and wait for the loading to complete.
    3. Open the notebook tab.
  2. Install the required modules:

    %pip install mlflow
    
  3. Import the required libraries:

    import os
    import warnings
    import sys
    
    import pandas as pd
    import numpy as np
    from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
    from sklearn.model_selection import train_test_split
    from sklearn.linear_model import ElasticNet
    from urllib.parse import urlparse
    import mlflow
    import mlflow.sklearn
    from mlflow.models import infer_signature
    import logging
    
  4. Create an experiment in MLFlow:

    mlflow.set_experiment("my_first_experiment")
    
  5. Create a function for prediction quality assessment:

    def eval_metrics(actual, pred):
      rmse = np.sqrt(mean_squared_error(actual, pred))
      mae = mean_absolute_error(actual, pred)
      r2 = r2_score(actual, pred)
      return rmse, mae, r2
    
  6. Get your data ready, train your model, and register it in MLflow:

    logging.basicConfig(level=logging.WARN)
    logger = logging.getLogger(__name__)
    
    warnings.filterwarnings("ignore")
    np.random.seed(40)
    
    # Uploading the dataset to assess wine quality
    csv_url = (
       "https://raw.githubusercontent.com/mlflow/mlflow/master/tests/datasets/winequality-red.csv"
    )
    try:
        data = pd.read_csv(csv_url, sep=";")
    except Exception as e:
        logger.exception(
            "Unable to download training & test CSV, check your internet connection. Error: %s", e
       )
    
    # Splitting the dataset into a training sample and a test sample
    train, test = train_test_split(data)
    
    # Allocating a target variable and variables used for prediction
    train_x = train.drop(["quality"], axis=1)
    test_x = test.drop(["quality"], axis=1)
    train_y = train[["quality"]]
    test_y = test[["quality"]]
    
    alpha = 0.5
    l1_ratio = 0.5
    
    # Creating an `mlflow` run
    with mlflow.start_run():
      
       # Creating and training the ElasticNet model
       lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)
       lr.fit(train_x, train_y)
      
       # Making quality predictions against the test sample
       predicted_qualities = lr.predict(test_x)
    
       (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities)
    
       print("Elasticnet model (alpha={:f}, l1_ratio={:f}):".format(alpha, l1_ratio))
       print("  RMSE: %s" % rmse)
       print("  MAE: %s" % mae)
       print("  R2: %s" % r2)
    
       # Logging data on hyperparameters and quality metrics in MLflow
       mlflow.log_param("alpha", alpha)
       mlflow.log_param("l1_ratio", l1_ratio)
       mlflow.log_metric("rmse", rmse)
       mlflow.log_metric("r2", r2)
       mlflow.log_metric("mae", mae)
    
       predictions = lr.predict(train_x)
       signature = infer_signature(train_x, predictions)
    
       tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
    
       # Registering the model in MLflow
       if tracking_url_type_store != "file":
         mlflow.sklearn.log_model(
               lr, "model", registered_model_name="ElasticnetWineModel", signature=signature
         )
       else:
          mlflow.sklearn.log_model(lr, "model", signature=signature)
    

    You can check the result at http://<VM_public_IP_address>:8000.

How to delete the resources you createdHow to delete the resources you created

To stop paying for the resources you created:

  • Delete the VM.
  • Delete the database cluster.
  • Delete the objects from the bucket.
  • Delete the bucket.
  • Delete the project.

Was the article helpful?

Previous
Exporting audit logs to SIEM Splunk systems
Next
Operations with data using Yandex Query
© 2025 Direct Cursus Technology L.L.C.