Skip to main content

A command-line utility to provision infrastructure for ML workflows

Project description

dstack is a lightweight command-line utility that lets you run ML workflows in the cloud, while keeping them highly reproducible.

Features

  • Define your ML workflows declaratively, incl. their dependencies, environment, and required compute resources
  • Run workflows via the dstack CLI. Have infrastructure provisioned automatically in a configured cloud account.
  • Save output artifacts, such as data and models, to reuse them in other ML workflows

Demo

How does it work?

  1. Install dstack locally
  2. Define ML workflows in .dstack/workflows.yaml (within your existing Git repository)
  3. Run ML workflows via the dstack run CLI command
  4. Use other dstack CLI commands to manage runs, artifacts, etc.

When you run an ML workflow via the dstack CLI, it provisions the required compute resources (in a configured cloud account), sets up environment (such as Python, Conda, CUDA, etc), fetches your code, downloads deps, saves artifacts, and tears down compute resources.

Installation

Use pip to install dstack locally:

pip install dstack

The dstack CLI needs your AWS account credentials to be configured locally (e.g. in ~/.aws/credentials or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables).

Before you can use the dstack CLI, you need to configure it:

dstack config

It will prompt you to select the AWS region where dstack will provision compute resources, and the S3 bucket, where dstack will save data.

AWS profile: default
AWS region: eu-west-1
S3 bucket: dstack-142421590066-eu-west-1
EC2 subnet: none

Support for GCP and Azure is in the roadmap.

Usage example

Say, you have a Python script that trains a model. It loads data from a local folder and saves the checkpoints into another folder.

Now, to make it possible to run it via dstack, you have to create a .dstack/workflows.yaml file, and define there how to run the script, where to load the data, how to store output artifacts, and what compute resources are needed to run it.

workflows: 
  - name: train
    provider: bash
    deps:
      - tag: mnist_data
    commands:
      - pip install requirements.txt
      - python src/train.py
    artifacts: 
      - path: checkpoint
    resources:
      interruptible: true
      gpu: 1

Now you can run it via the dstack CLI:

dstack run train

You'll see the output in real-time as your workflow is running.

Provisioning... It may take up to a minute. ✓

To interrupt, press Ctrl+C.

Epoch 4: 100%|██████████████| 1876/1876 [00:17<00:00, 107.85it/s, loss=0.0944, v_num=0, val_loss=0.108, val_acc=0.968]

`Trainer.fit` stopped: `max_epochs=5` reached.

Testing DataLoader 0: 100%|██████████████| 313/313 [00:00<00:00, 589.34it/s]

Test metric   DataLoader 0
val_acc       0.965399980545044
val_loss      0.10975822806358337

Use the dstack ps command to see the status of recent workflows.

dstack ps -a

RUN               TARGET    SUBMITTED    OWNER           STATUS   TAG
angry-elephant-1  download  8 hours ago  peterschmidt85  Done     mnist_data
wet-insect-1      train     1 weeks ago  peterschmidt85  Running  

Other CLI commands allow to manage runs, artifacts, tags, secrets, and more.

You can use dstack to not only process data or train models, but also to run applications, and dev environments.

All the state and output artifacts are stored in a configured S3 bucket.

More information

Licence

Mozilla Public License 2.0

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dstack-0.0.12.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

dstack-0.0.12-py3-none-any.whl (6.7 MB view details)

Uploaded Python 3

File details

Details for the file dstack-0.0.12.tar.gz.

File metadata

  • Download URL: dstack-0.0.12.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for dstack-0.0.12.tar.gz
Algorithm Hash digest
SHA256 940e6886060777c19222e42011361654b4353db773d41042c0cfe13f9b7de325
MD5 7e609f2b98cbf07b2b5b3fc1029492e4
BLAKE2b-256 df999b0aa42ed14a8d07b0400c6ba241a6932139c9cce08a62d3a348e234fc18

See more details on using hashes here.

File details

Details for the file dstack-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: dstack-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 6.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for dstack-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 873e0cdf75122681386772ad7c95bcfc9f81d37f0ecfd90b36ce156518ce26a8
MD5 3dc0de630bafa54463ea896b69dffcea
BLAKE2b-256 1a7413a1762a7cd97df1cc2054ba260c0d0c815a8f5abfab4361295c82c42c7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page