Skip to main content

Develop ML faster. Easily and cost-effectively run dev environments, pipelines, and apps on any cloud.

Project description

dstack

Develop ML faster. Use any cloud.

DocsExamplesBlogSlack

Last commit PyPI - License

dstack makes it very easy for ML engineers to run dev environments, pipelines and apps cost-effectively on any cloud.

Installation and setup

To use dstack, install it with pip and start the Hub application.

pip install "dstack[aws,gcp,azure]"
dstack start

The dstack start command starts the Hub server, and creates the default project to run everything locally.

To enable Hub to run dev environments, pipelines, and apps in your preferred cloud account (AWS, GCP, Azure, etc), log in to Hub, and configure the corresponding project.

Running a dev environment

A dev environment is a virtual machine that includes the environment and an interactive IDE or notebook setup based on a pre-defined configuration.

Go ahead and define this configuration via YAML (under the .dstack/workflows folder).

workflows:
  - name: code-gpu
    provider: code
    setup:
      - pip install -r dev-environments/requirements.txt
    resources:
      gpu:
        count: 1

The YAML file allows you to configure hardware resources, set up the Python environment, expose ports, configure cache, and many more.

Now, you can start it using the dstack run command:

$ dstack run code-gpu

RUN      WORKFLOW  SUBMITTED  STATUS     TAG
shady-1  code-gpu  now        Submitted  
 
Starting SSH tunnel...

To exit, press Ctrl+C.

Web UI available at http://127.0.0.1:10000/?tkn=4d9cc05958094ed2996b6832f899fda1

If you configure a project to run dev environments in the cloud, dstack will automatically provision the required cloud resources, and forward ports of the dev environment to your local machine.

When you stop the dev environment, dstack will automatically clean up cloud resources.

Running a pipeline

A pipeline is a set of pre-defined configurations that allow to process data, train or fine-tune models, do batch inference or other tasks.

Go ahead and define such a configuration via YAML (under the .dstack/workflows folder).

workflows:
  - name: train-mnist-gpu
    provider: bash
    commands:
      - pip install -r pipelines/requirements.txt
      - python pipelines/train.py
    artifacts:
      - ./lightning_logs
    resources:
      gpu:
        count: 1

The YAML file allows you to configure hardware resources and output artifacts, set up the Python environment, expose ports, configure cache, and many more.

Now, you can run the pipeline using the dstack run command:

$ dstack run train-mnist-gpu

RUN      WORKFLOW         SUBMITTED  STATUS     TAG
shady-1  train-mnist-gpu  now        Submitted  
 
Provisioning... It may take up to a minute. ✓

GPU available: True, used: True

Epoch 1: [00:03<00:00, 280.17it/s, loss=1.35, v_num=0]

If you configure a project to run pipelines in the cloud, the dstack run command will automatically provision the required cloud resources.

After the pipeline is stopped or finished, dstack will save output artifacts and clean up cloud resources.

Running an app

An app can be either a web application (such as Streamlit, Gradio, etc.) or an API endpoint (like FastAPI, Flask, etc.) setup based on a pre-defined configuration.

Go ahead and define this configuration via YAML (under the .dstack/workflows folder).

workflows:
  - name: fastapi-gpu
    provider: bash
    ports:
      - 3000
    commands:
      - pip install -r apps/requirements.txt
      - uvicorn apps.main:app --port 3000 --host 0.0.0.0
    resources:
      gpu:
        count: 1

The configuration allows you to customize hardware resources, set up the Python environment, configure cache, and more.

Now, you can run the app using the dstack run command:

$ dstack run fastapi-gpu
 RUN           WORKFLOW     SUBMITTED  STATUS     TAG
 silly-dodo-1  fastapi-gpu  now        Submitted     

Starting SSH tunnel...

To interrupt, press Ctrl+C.

INFO:     Started server process [1]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)

If you configure a project to run apps in the cloud, dstack will automatically provision the required cloud resources, and forward ports of the app to your local machine. If you stop the app, it will automatically clean up cloud resources.

More information

For additional information and examples, see the following links:

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.9.2.tar.gz (137.9 kB view details)

Uploaded Source

Built Distribution

dstack-0.9.2-py3-none-any.whl (13.7 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dstack-0.9.2.tar.gz
  • Upload date:
  • Size: 137.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for dstack-0.9.2.tar.gz
Algorithm Hash digest
SHA256 9ee91118028641f0710d324a65afb02078fe40fabc5dc41be78f6f989150affa
MD5 612511db6b59fbb011bb0a56ba57cf0e
BLAKE2b-256 a50fc4d5fefaebef7a838bffa82af4351f51856d0d7cb1528f9f932095812f77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dstack-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for dstack-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c15a378f6afc835cfb2911b3b45152b3374c2c66f30e5450f0e13fd2a312ad52
MD5 6fe516764ae6ca8b0e7e0528ca494b4b
BLAKE2b-256 84e3f5e59464e4892c383112621f5af76849c200fb12fa93122891be1334f5ad

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