Skip to main content

dstack is an open-source framework for orchestration GPU workloads and development of generative AI models across multiple clouds.

Project description

dstack

Orchestrate GPU workloads across clouds

DocsExamplesBlogSlack

Last commit PyPI - License

dstack is an open-source framework for orchestrating GPU workloads across multiple cloud GPU providers. It provides a simple cloud-agnostic interface for development and deployment of generative AI models.

Latest news ✨

Installation

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

pip install "dstack[all]" -U
dstack start

Configure clouds

Upon startup, the server sets up the default project called main. Prior to using dstack, make sure to configure clouds.

Once the server is up, you can orchestrate GPU workloads using either the CLI or Python API.

Using CLI

Define a configuration

The CLI allows you to define what you want to run as a YAML file and run it via the dstack run CLI command.

Configurations can be of three types: dev-environment, task, and service.

Dev environments

A dev environment is a virtual machine with a pre-configured IDE.

type: dev-environment

python: "3.11" # (Optional) If not specified, your local version is used

setup: # (Optional) Executed once at the first startup
  - pip install -r requirements.txt

ide: vscode

Tasks

A task can be either a batch job, such as training or fine-tuning a model, or a web application.

type: task

python: "3.11" # (Optional) If not specified, your local version is used

ports:
  - 7860

commands:
  - pip install -r requirements.txt
  - python app.py

While the task is running in the cloud, the CLI forwards its ports traffic to localhost for convenient access.

Services

A service is an application that is accessible through a public endpoint.

type: service

port: 7860

commands:
  - pip install -r requirements.txt
  - python app.py

Once the service is up, dstack makes it accessible from the Internet through the gateway.

Run a configuration

To run a configuration, use the dstack run command followed by working directory and the path to the configuration file.

dstack run . -f text-generation-inference/serve.dstack.yml --gpu 80GB -y

 RUN           BACKEND  INSTANCE              SPOT  PRICE STATUS    SUBMITTED
 tasty-zebra-1 lambda   200GB, 1xA100 (80GB)  no    $1.1  Submitted now
 
Privisioning...

Serving on https://tasty-zebra-1.mydomain.com

Using API

As an alternative to the CLI, you can run tasks and services programmatically via Python API.

import sys

import dstack

task = dstack.Task(
    image="ghcr.io/huggingface/text-generation-inference:latest",
    env={"MODEL_ID": "TheBloke/Llama-2-13B-chat-GPTQ"},
    commands=[
        "text-generation-launcher --trust-remote-code --quantize gptq",
    ],
    ports=["8080:80"],
)
resources = dstack.Resources(gpu=dstack.GPU(memory="20GB"))

if __name__ == "__main__":
    print("Initializing the client...")
    client = dstack.Client.from_config(repo_dir="~/dstack-examples")

    print("Submitting the run...")
    run = client.runs.submit(configuration=task, resources=resources)

    print(f"Run {run.name}: " + run.status())

    print("Attaching to the run...")
    run.attach()

    # After the endpoint is up, http://127.0.0.1:8080/health will return 200 (OK).

    try:
        for log in run.logs():
            sys.stdout.buffer.write(log)
            sys.stdout.buffer.flush()

    except KeyboardInterrupt:
        print("Aborting the run...")
        run.stop(abort=True)
    finally:
        run.detach()

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.11.3rc1.tar.gz (184.0 kB view details)

Uploaded Source

Built Distribution

dstack-0.11.3rc1-py3-none-any.whl (13.9 MB view details)

Uploaded Python 3

File details

Details for the file dstack-0.11.3rc1.tar.gz.

File metadata

  • Download URL: dstack-0.11.3rc1.tar.gz
  • Upload date:
  • Size: 184.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for dstack-0.11.3rc1.tar.gz
Algorithm Hash digest
SHA256 4466c16f33908bb070976e2e52080562f229ead9a90ea63d71ac1db9c4f378e5
MD5 686230e091f584615d4e3e1e93e39cff
BLAKE2b-256 e4087680830708a1e1407d1d1a6cd2ac49b6565edf5085b8841c67c540570909

See more details on using hashes here.

File details

Details for the file dstack-0.11.3rc1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dstack-0.11.3rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 a42eb3988a172da27b254f422ba20afa2b899dfd8108d8462864d48d46191d29
MD5 ab100376365f2e213e7b120166e5d05f
BLAKE2b-256 14c0fda452f0b8a0980d1e7d56bce0311a70429bd7b9ea193d2fbb08c7851f3d

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