### Initialize Termynal for Get Started Example Source: https://github.com/dstackai/dstack/blob/master/docs/overrides/home.html Initializes a Termynal instance for the 'Get Started' section, simulating command-line interactions for installing dstack, adding skills, and starting the server. It includes progress simulation and specific output messages. ```javascript function initCarouselTermynal(terminalId, lineData) { var termEl = document.getElementById(terminalId); if (!termEl) return null; var slide = termEl.closest('.code-carousel__slide'); if (slide) slide.style.display = 'block'; var termynal = new Termynal(termEl, { lineData: lineData }); var termH = termEl.style.minHeight; if (termH) { var carousel = termEl.closest('.code-carousel'); var codeEl = carousel && carousel.querySelector('code[editor-title]'); if (codeEl) { codeEl.style.minHeight = termH; codeEl.style.boxSizing = 'border-box'; } } if (slide) slide.style.display = ''; return termynal; } function normalizeCarouselHeight(carousel) { var slidesWrap = carousel.querySelector('.code-carousel__slides'); if (!slidesWrap) return; var slides = Array.prototype.slice.call(carousel.querySelectorAll('.code-carousel__slide')); if (!slides.length) return; var maxHeight = 0; slides.forEach(function(slide) { var prevDisplay = slide.style.display; var prevVisibility = slide.style.visibility; if (!slide.classList.contains('active')) { slide.style.display = 'block'; slide.style.visibility = 'hidden'; } maxHeight = Math.max(maxHeight, slide.scrollHeight, slide.offsetHeight); if (!slide.classList.contains('active')) { slide.style.display = prevDisplay; slide.style.visibility = prevVisibility; } }); if (maxHeight > 0) { slidesWrap.style.minHeight = maxHeight + 'px'; slides.forEach(function(slide) { slide.style.minHeight = maxHeight + 'px'; }); } } window._getStartedTermynal = initCarouselTermynal('get-started-code-snippet', [ {type: 'input', value: 'uv tool install "dstack[all]" -U'}, {delay: 0, value: 'Downloading dstack-0.20.15-py3-none-any.whl', class: 'newline'}, {type: 'progress', progressPercent: 100, typeDelay: 50}, {delay: 0, value: ' ', class: 'newline'}, {type: 'input', value: 'npx skills add dstackai/dstack'}, {delay: 0, value: 'Installed skill dstack from dstackai/dstack', class: 'newline'}, {delay: 0, value: ' ', class: 'newline'}, {type: 'input', value: 'dstack server'}, {delay: 0, value: ' ', class: 'newline'}, {delay: 0, value: 'Applying ~/.dstack/server/config.yml...', class: 'newline'}, {delay: 0, value: ' ', class: 'newline'}, {delay: 0, value: 'The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da"', class: 'newline'}, {delay: 0, value: 'The server is running at http://127.0.0.1:3000/', class: 'newline'}, ]); ``` -------------------------------- ### Start Plugin Server Source: https://github.com/dstackai/dstack/blob/master/examples/plugins/example_plugin_server/README.md Run this command to start the example plugin server. ```bash python -m example_plugin_server.main ``` -------------------------------- ### Install and Start Dstack Server Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/digitalocean-and-amd-dev-cloud.md Install the dstack server using pip and start the server process. Ensure you have the necessary dependencies installed. ```shell pip install "dstack[server]" dstack server ``` -------------------------------- ### Install Plugin Server Source: https://github.com/dstackai/dstack/blob/master/examples/plugins/example_plugin_server/README.md Use this command to install the example plugin server package. ```bash uv pip install examples/plugins/example_plugin_server ``` -------------------------------- ### Install and Start dstack Server Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/nebius.md Install the dstack package with Nebius support and start the dstack server. This is a prerequisite for using dstack with Nebius. ```shell pip install "dstack[nebius]" dstack server ``` -------------------------------- ### Install dstack CLI and Server Source: https://context7.com/dstackai/dstack/llms.txt Install the dstack server and CLI using pip or uv. After installation, start the dstack server to manage GPU resources. ```bash # Install with uv (recommended) uv tool install "dstack[all]" -U # Or install with pip pip install "dstack[all]" -U # Start the dstack server dstack server # Output: # Applying ~/.dstack/server/config.yml... # The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" # The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Initialize Dev Environment with Commands Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/dev-environments.md Pre-configure your dev environment by specifying a list of commands to run at startup using the `init` property. This example installs the `wandb` package. ```yaml type: dev-environment name: vscode python: "3.11" ide: vscode init: - pip install wandb ``` -------------------------------- ### Run Dstack Server Source: https://github.com/dstackai/dstack/blob/master/contributing/FRONTEND.md Start the dstack server. This command assumes dstack is installed in editable mode. ```shell dstack server ``` -------------------------------- ### Navigate to Frontend Directory Source: https://github.com/dstackai/dstack/blob/master/contributing/FRONTEND.md Change the current directory to the frontend folder to begin setup. ```shell cd frontend ``` -------------------------------- ### Install and Run dstack Server with uv Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/server-deployment.md This method uses 'uv' for installing the dstack server. It requires Git and OpenSSH to be present on your system. ```shell $ uv tool install 'dstack[all]' -U $ dstack server Applying ~/.dstack/server/config.yml... The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/dstackai/dstack/blob/master/contributing/DEVELOPMENT.md Install pre-commit hooks to automate code formatting and linting on each commit. This requires uv to be installed. ```shell uv run pre-commit install ``` -------------------------------- ### Install dstack server with uv Source: https://github.com/dstackai/dstack/blob/master/docs/docs/installation.md Installs the dstack server and its dependencies using uv. Requires Git and OpenSSH. ```shell $ uv tool install "dstack[all]" -U $ dstack server Applying ~/.dstack/server/config.yml... The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Install dstack CLI with uv Source: https://github.com/dstackai/dstack/blob/master/docs/docs/installation.md Installs the dstack CLI using uv. Requires Git and OpenSSH. ```shell $ uv tool install dstack -U ``` -------------------------------- ### Install TRL and Dependencies Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/benchmark-amd-vms.md Installs the TRL library, PyTorch with ROCm support, and other necessary packages within the development container. This setup is required before running training benchmarks. ```shell sudo apt-get update && sudo apt-get install -y git cmake && \ pip install torch --index-url https://download.pytorch.org/whl/nightly/rocm6.4 && \ pip install transformers peft wandb && \ git clone https://github.com/huggingface/trl && \ cd trl && \ pip install . ``` -------------------------------- ### Install NPM Dependencies Source: https://github.com/dstackai/dstack/blob/master/contributing/FRONTEND.md Install all necessary Node.js dependencies for the frontend using npm. ```shell npm install ``` -------------------------------- ### Backend Fleet with Pre-provisioning Nodes Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/fleets.md Use a `nodes` range starting above 0 to pre-provision instances. Additional instances are provisioned on demand. This example allows provisioning up to 8 H100 GPUs. ```yaml type: fleet name: my-fleet nodes: 2..10 # Uncomment to ensure instances are inter-connected #placement: cluster resources: gpu: H100:8 ``` -------------------------------- ### Install dstack Server Source: https://github.com/dstackai/dstack/blob/master/README.md Installs the dstack server with all features. Ensure you have Git and OpenSSH installed. The server requires backend configuration for cloud or Kubernetes, but not for on-prem servers. ```shell $ uv tool install "dstack[all]" -U $ dstack server Applying ~/.dstack/server/config.yml... The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Install Dstack CLI with pip Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/nebius-in-dstack-sky.md Use 'pip' to install the Dstack CLI. This is a standard Python package installation. ```shell $ pip install dstack -U ``` -------------------------------- ### Start dstack Server with Docker Source: https://github.com/dstackai/dstack/blob/master/docker/server/README.md Run the dstack server using Docker. Ensure the necessary volume is mounted for server configuration. ```shell docker run -p 3000:3000 -v $HOME/.dstack/server/:/root/.dstack/server dstackai/dstack ``` -------------------------------- ### Run QLoRA Fine-tuning Task Source: https://github.com/dstackai/dstack/blob/master/examples/single-node-training/qlora/README.md Execute the dstack apply command with a specified YAML configuration file to start the QLoRA fine-tuning process. ```shell dstack apply -f examples/single-node-training/qlora/.dstack.yml ``` -------------------------------- ### Install dstack server with pip Source: https://github.com/dstackai/dstack/blob/master/docs/docs/installation.md Installs the dstack server and its dependencies using pip. Requires Git and OpenSSH. ```shell $ pip install "dstack[all]" -U $ dstack server Applying ~/.dstack/server/config.yml... The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Install dstack CLI Source: https://github.com/dstackai/dstack/blob/master/README.md Installs the dstack CLI. This is required to interact with a running dstack server. Ensure Git and OpenSSH are installed. ```shell $ uv tool install dstack -U ``` -------------------------------- ### GPU Specification Examples Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/protips.md These examples demonstrate various ways to specify GPU requirements, including vendor, model, memory, and quantity ranges. Each component is optional, and ranges can be closed, open, or single values. ```shell 1 ``` ```shell amd:2 ``` ```shell A100 ``` ```shell 24GB.. ``` ```shell 24GB..40GB:2 ``` ```shell A10G,A100 ``` ```shell A100:80GB ``` ```shell A100:2 ``` ```shell MI300X:4 ``` ```shell A100:40GB:2 ``` ```shell tpu:v2-8 ``` -------------------------------- ### Install Ray Locally Source: https://github.com/dstackai/dstack/blob/master/examples/distributed-training/ray-ragen/README.md Installs the Ray library locally to enable submission of jobs to a Ray cluster. ```shell pip install ray ``` -------------------------------- ### Install dstack with Fluent-bit extras Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/server-deployment.md Install the necessary extras for Fluent-bit log storage functionality. This command installs all optional dependencies, including Fluent-bit. ```shell $ pip install "dstack[all]" -U ``` -------------------------------- ### Install dstack with Fluent-bit specific extras Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/server-deployment.md Install only the Fluent-bit specific dependencies for log storage. This is a more targeted installation if you only need Fluent-bit functionality. ```shell $ pip install "dstack[fluentbit]" -U ``` -------------------------------- ### Usage Example: Submitting a Task and Displaying Logs Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/api/python/index.md This example demonstrates how to submit a task for running using the DStack Python API and how to retrieve and display its logs. ```APIDOC ## Usage Example: Submitting a Task and Displaying Logs Below is a quick example of submitting a task for running and displaying its logs. ```python import sys from dstack.api import Task, GPU, Client, Resources client = Client.from_config() task = Task( name="my-awesome-run", # If not specified, a random name is assigned 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=["80"], resources=Resources(gpu=GPU(memory="24GB")), ) run = client.runs.apply_configuration( configuration=task, # Can be Task, Service, or DevEnvironment repo=None, # Specify to mount additional files ) run.attach() # Waits for the run to start and forwards configured ports to localhost try: for log in run.logs(): sys.stdout.buffer.write(log) sys.stdout.buffer.flush() except KeyboardInterrupt: run.stop(abort=True) finally: run.detach() ``` !!! info "NOTE:" 1. The `configuration` argument in the `apply_configuration` method can be either `dstack.api.Task`, `dstack.api.Service`, or `dstack.api.DevEnvironment`. 2. When you create `dstack.api.Task`, `dstack.api.Service`, or `dstack.api.DevEnvironment`, you can specify the `image` argument. If `image` isn't specified, the default image will be used. For a private Docker registry, ensure you also pass the `registry_auth` argument. 3. The `repo` argument in the `apply_configuration` method allows the mounting of a remote repo or a programmatically created repo. In this case, the `commands` argument can refer to the files within this repo. 4. The `attach` method waits for the run to start and, for `dstack.api.Task` sets up an SSH tunnel and forwards configured `ports` to `localhost`. ``` -------------------------------- ### Start Local Shim Source: https://github.com/dstackai/dstack/blob/master/runner/README.md Starts the dstack-shim locally. Requires specifying the shim home directory and the path to the compiled runner binary. ```shell ./shim --shim-home $RUNNER_DIR --runner-binary-path $COMPILED_RUNNER_PATH ``` -------------------------------- ### Install dstack CLI with pip Source: https://github.com/dstackai/dstack/blob/master/docs/docs/installation.md Installs the dstack CLI using pip. Requires Git and OpenSSH. ```shell $ pip install dstack -U ``` -------------------------------- ### Display dstack init Help Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/cli/dstack/init.md Use `dstack init --help` to view available options for initializing dstack and configuring Git credentials. ```shell $ dstack init --help ``` -------------------------------- ### Schedule Service Start Time Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/services.md Define a schedule to start a service periodically at specific UTC times using cron syntax. This example schedules the service to start at 8:00 AM UTC from Monday through Friday. ```yaml type: service name: llama-2-7b-service python: 3.12 env: - HF_TOKEN - MODEL=NousResearch/Llama-2-7b-chat-hf commands: - uv pip install vllm - python -m vllm.entrypoints.openai.api_server --model $MODEL --port 8000 port: 8000 resources: gpu: 24GB schedule: cron: "0 8 * * mon-fri" # at 8:00 UTC from Monday through Friday ``` -------------------------------- ### Schedule Dev Environment Start Time Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/dev-environments.md Use the schedule property with cron syntax in .dstack.yml to start a dev environment periodically at specific UTC times. This example starts the environment at 8:00 UTC on weekdays. ```yaml type: dev-environment ide: vscode schedule: cron: "0 8 * * mon-fri" # at 8:00 UTC from Monday through Friday ``` -------------------------------- ### Prepare Development Environment on Gateway Source: https://github.com/dstackai/dstack/blob/master/contributing/PROXY.md Sets up the development environment on the gateway by checking out the branch, installing uv, and syncing dependencies. Ensure you are in the cloned repository directory. ```shell cd ~/dstack-repo git checkout branch_name curl -LsSf https://astral.sh/uv/install.sh | sh source ~/.local/bin/env uv sync --extra gateway ``` -------------------------------- ### Preview Documentation Source: https://github.com/dstackai/dstack/blob/master/contributing/DOCS.md Run this command to preview the documentation locally. The server will watch for changes. ```shell uv run mkdocs serve -w examples -s ``` -------------------------------- ### Run a Streamlit app as a dstack task Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/protips.md Configure a dstack task to run a Streamlit application. This example uses Python 3.12 and installs Streamlit using uv pip. ```yaml type: task name: streamlit-task python: 3.12 commands: - uv pip install streamlit - streamlit hello ports: - 8501 ``` -------------------------------- ### List Available Offers Source: https://github.com/dstackai/dstack/blob/master/skills/dstack/SKILL.md Lists available instance configurations. Filters can be applied by backend, GPU type, GPU memory, or fleet. Use '--json' for scriptable output. ```bash dstack offer --backend aws ``` ```bash dstack offer --gpu A100 ``` ```bash dstack offer --gpu 24GB..80GB ``` ```bash dstack offer --backend aws --gpu A100:80GB ``` ```bash dstack offer --fleet my-fleet ``` ```bash dstack offer --fleet my-fleet --fleet other-fleet ``` ```bash dstack offer --json ``` -------------------------------- ### Interact with the deployed service via proxy Source: https://github.com/dstackai/dstack/blob/master/examples/inference/nim/README.md Send a POST request to the service endpoint using `curl` to get chat completions. This example assumes no gateway is configured and uses the proxy endpoint. ```shell curl http://127.0.0.1:3000/proxy/services/main/nemotron120/v1/chat/completions \ -X POST \ -H 'Authorization: Bearer ' -H 'Content-Type: application/json' \ -d '{ "model": "nvidia/nemotron-3-super-120b-a12b", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is Deep Learning?" } ], "max_tokens": 128 }' ``` -------------------------------- ### Create a project directory Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/amd-on-tensorwave.md Before defining your fleet, create a project folder and navigate into it. ```shell mkdir tensorwave-demo && cd tensorwave-demo ``` -------------------------------- ### Define Ray Cluster Task Source: https://github.com/dstackai/dstack/blob/master/examples/misc/ray/README.md Task definition for launching Ray master and worker nodes. Installs Ray, starts the head node on rank 0, and workers on other nodes. Makes the Ray dashboard available. ```yaml type: task name: ray-cluster nodes: 4 commands: - pip install -U "ray[default]" - | if [ $DSTACK_NODE_RANK = 0 ]; then ray start --head --port=6379; else ray start --address=$DSTACK_MASTER_NODE_IP:6379 fi ports: - 8265 # ray dashboard port resources: shm_size: 8GB ``` -------------------------------- ### Deploy LLM with vLLM on TPU Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/tpu-on-gcp.md Deploy Llama 3.1 8B using vLLM on a TPU. This example includes specific pip installations for PyTorch XLA and vLLM, along with environment variables for configuration. Ensure HF_TOKEN is set. ```yaml type: service name: llama31-service-vllm-tpu env: - MODEL_ID=meta-llama/Meta-Llama-3.1-8B-Instruct - HF_TOKEN - DATE=20240828 - TORCH_VERSION=2.5.0 - VLLM_TARGET_DEVICE=tpu - MAX_MODEL_LEN=4096 commands: - pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch-${TORCH_VERSION}.dev${DATE}-cp311-cp311-linux_x86_64.whl - pip3 install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-${TORCH_VERSION}.dev${DATE}-cp311-cp311-linux_x86_64.whl - pip install torch_xla[tpu] -f https://storage.googleapis.com/libtpu-releases/index.html - pip install torch_xla[pallas] -f https://storage.googleapis.com/jax-releases/jax_nightly_releases.html -f https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html - git clone https://github.com/vllm-project/vllm.git - cd vllm - pip install -r requirements-tpu.txt - apt-get install -y libopenblas-base libopenmpi-dev libomp-dev - python setup.py develop - vllm serve $MODEL_ID --tensor-parallel-size 4 --max-model-len $MAX_MODEL_LEN --port 8000 port: 8000 # Register the model model: meta-llama/Meta-Llama-3.1-8B-Instruct # Uncomment to leverage spot instances #spot_policy: auto resources: gpu: v5litepod-4 ``` -------------------------------- ### Configure Distributed PyTorch Training Task Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/kubernetes-beta.md Define a dstack task for distributed PyTorch training using `torchrun`. This includes cloning the PyTorch examples repository, installing dependencies, and executing the training script with appropriate distributed parameters. ```yaml type: task name: train-distrib nodes: 2 python: 3.12 env: - NCCL_DEBUG=INFO commands: - git clone https://github.com/pytorch/examples.git pytorch-examples - cd pytorch-examples/distributed/ddp-tutorial-series - uv pip install -r requirements.txt - | torchrun \ --nproc-per-node=$DSTACK_GPUS_PER_NODE \ --node-rank=$DSTACK_NODE_RANK \ --nnodes=$DSTACK_NODES_NUM \ --master-addr=$DSTACK_MASTER_NODE_IP \ --master-port=12345 \ multinode.py 50 10 resources: gpu: 1..8 shm_size: 16GB ``` -------------------------------- ### Build Static Documentation Source: https://github.com/dstackai/dstack/blob/master/contributing/DOCS.md Use this command to build static HTML files for the documentation. ```shell uv run mkdocs build -s ``` -------------------------------- ### Configure Distributed PyTorch Training with Torchrun Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/tasks.md Use this configuration to run distributed PyTorch training across multiple nodes. It clones a PyTorch example, installs dependencies, and launches the training script using torchrun with necessary distributed parameters. ```yaml type: task name: train-distrib nodes: 2 python: 3.12 env: - NCCL_DEBUG=INFO commands: - git clone https://github.com/pytorch/examples.git pytorch-examples - cd pytorch-examples/distributed/ddp-tutorial-series - uv pip install -r requirements.txt - | torchrun \ --nproc-per-node=$DSTACK_GPUS_PER_NODE \ --node-rank=$DSTACK_NODE_RANK \ --nnodes=$DSTACK_NODES_NUM \ --master-addr=$DSTACK_MASTER_NODE_IP \ --master-port=12345 \ multinode.py 50 10 resources: gpu: 24GB:1..2 shm_size: 24GB ``` -------------------------------- ### Distributed Training with DStack Environment Variables Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/environment-variables.md This task configures distributed training using PyTorch's `torchrun`. It leverages `DSTACK_GPUS_PER_NODE`, `DSTACK_NODE_RANK`, `DSTACK_NODES_NUM`, and `DSTACK_MASTER_NODE_IP` to set up the distributed environment. The example clones a PyTorch DDP tutorial and installs its requirements. ```yaml type: task name: train-distrib # The size of the cluster nodes: 2 python: 3.12 env: - NCCL_DEBUG=INFO commands: - git clone https://github.com/pytorch/examples.git pytorch-examples - cd pytorch-examples/distributed/ddp-tutorial-series - uv pip install -r requirements.txt - | torchrun \ --nproc-per-node=$DSTACK_GPUS_PER_NODE \ --node-rank=$DSTACK_NODE_RANK \ --nnodes=$DSTACK_NODES_NUM \ --master-addr=$DSTACK_MASTER_NODE_IP \ --master-port=12345 \ multinode.py 50 10 resources: gpu: 24GB:1..2 # Uncomment if using multiple GPUs #shm_size: 24GB ``` -------------------------------- ### Configure Digital Ocean Backend Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/backends.md Set up the Digital Ocean backend by providing your project name and API key. The `project_name` is optional; if omitted, the default project will be used. ```yaml projects: - name: main backends: - type: digitalocean project_name: my-digital-ocean-project creds: type: api_key api_key: ... ``` -------------------------------- ### Task with Private Registry Authentication Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/tasks.md Configures a task to pull a Docker image from a private NVIDIA NGC registry using provided credentials. It clones PyTorch examples, installs requirements, and runs a distributed training job using 'torchrun'. Requires GPU resources and NGC API key. ```yaml type: task name: train env: - NGC_API_KEY image: nvcr.io/nvidia/pytorch:25.05-py3 registry_auth: username: $oauthtoken password: ${{ env.NGC_API_KEY }} commands: - git clone https://github.com/pytorch/examples.git pytorch-examples - cd pytorch-examples/distributed/ddp-tutorial-series - pip install -r requirements.txt - | torchrun \ --nproc-per-node=$DSTACK_GPUS_PER_NODE \ --nnodes=$DSTACK_NODES_NUM \ multinode.py 50 10 resources: gpu: H100:1..2 shm_size: 24GB ``` -------------------------------- ### dstack DinD Service Configuration Source: https://github.com/dstackai/dstack/blob/master/docker/dind/README.md Configure a dstack service to use the NVIDIA Docker in Docker image. This setup includes starting the Docker daemon, listing images, running GPU-accelerated containers, and executing Docker Compose applications. Ensure the `privileged` option is set to `true` for Docker daemon operations. ```yaml type: service name: dind image: dstackai/dind privileged: true port: 3000 auth: false commands: # start docker daemon - start-dockerd # list stored images - docker image ls # run docker with nvidia gpu example (nvidia-smi) - docker run --rm --gpus all debian nvidia-smi # run docker compose example (gitea+postgres) - git clone --depth 1 https://github.com/docker/awesome-compose.git - cd awesome-compose/gitea-postgres - docker compose up # preserve docker data root between runs (including volumes and image store) volumes: - name: dind-volume path: /var/lib/docker ``` -------------------------------- ### Start vLLM Server Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/benchmark-amd-vms.md Initiates the vLLM server to host the specified language model. This command is used after entering the vLLM Docker container. ```shell vllm serve meta-llama/Llama-3.3-70B-Instruct --max-model-len 100000 ``` -------------------------------- ### Display dstack project list Help Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/cli/dstack/project.md View the help information for the `dstack project list` command to understand how to list all configured projects on the client. ```shell $ dstack project list --help ``` -------------------------------- ### Display help for dstack offer Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/cli/dstack/offer.md Use the `--help` flag to view all available options and arguments for the `dstack offer` command. ```shell $ dstack offer --help ``` -------------------------------- ### Show dstack apply plan Source: https://github.com/dstackai/dstack/blob/master/skills/dstack/SKILL.md Use this command to preview the plan for applying a dstack configuration without executing it. It's recommended to use `echo "n" |` for previewing. ```bash echo "n" | dstack apply -f ``` -------------------------------- ### Install uv Source: https://github.com/dstackai/dstack/blob/master/contributing/DEVELOPMENT.md Install the uv package manager using the provided installation script. This is a prerequisite for managing dstack's dependencies. ```shell curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Inspect available instance offers Source: https://github.com/dstackai/dstack/blob/master/docs/docs/guides/troubleshooting.md Use the 'dstack offer' command to inspect available instance offers. You can filter by GPU type or specify a fleet to see offers available through that fleet. ```shell # All matching offers, ignoring fleet configurations $ dstack offer --gpu H100 # Offers available through a specific fleet $ dstack offer --gpu H100 --fleet my-fleet ``` -------------------------------- ### Initialize a DStack Plugin Library Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/plugins/python/index.md Use the `uv init --library` command to initialize a new Python package intended to be a DStack plugin. ```shell $ uv init --library ``` -------------------------------- ### Install dstack with Extras Source: https://github.com/dstackai/dstack/blob/master/contributing/DEVELOPMENT.md Install dstack with all optional extras and development dependencies using uv. This command installs dstack in editable mode into the project's .venv. ```shell uv sync --all-extras ``` -------------------------------- ### Configure dstack Server with Remote Binaries Source: https://github.com/dstackai/dstack/blob/master/runner/README.md Starts the dstack server, providing URLs for downloading the shim and runner binaries from S3. This allows testing with standard backends. ```shell export DSTACK_SHIM_DOWNLOAD_URL="https://${DSTACK_SHIM_UPLOAD_S3_BUCKET}.s3.amazonaws.com/${DSTACK_SHIM_UPLOAD_VERSION}/binaries/dstack-shim-linux-amd64" export DSTACK_RUNNER_DOWNLOAD_URL="https://${DSTACK_SHIM_UPLOAD_S3_BUCKET}.s3.amazonaws.com/${DSTACK_SHIM_UPLOAD_VERSION}/binaries/dstack-runner-linux-amd64" dstack server --log-level=debug ``` -------------------------------- ### dstack apply command with Runpod backend Source: https://github.com/dstackai/dstack/blob/master/docs/docs/concepts/backends.md Example command to apply a dstack configuration using the Runpod backend. It lists available instances in different regions. ```shell dstack apply -f .dstack.yml -b runpod ``` -------------------------------- ### Deploy Qwen2.5-Instruct Service with dstack Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/agentic-orchestration.md Defines a dstack service for the Qwen2.5-32B-Instruct model, specifying image, environment variables, commands, port, model details, replicas, scaling, and resources. ```yaml type: service name: qwen25-instruct image: lmsysorg/sglang:latest env: - MODEL_ID=Qwen/Qwen2.5-32B-Instruct commands: - | python -m sglang.launch_server \ --model-path $MODEL_ID \ --port 8000 \ --trust-remote-code port: 8000 model: Qwen/Qwen2.5-32B-Instruct replicas: 1..4 scaling: metric: rps target: 10 resources: gpu: 80GB disk: 200GB ``` -------------------------------- ### Interact with Shim Client Source: https://github.com/dstackai/dstack/blob/master/runner/README.md Demonstrates how to connect to the local shim service using the dstack client and submit a run. ```python >>> from dstack._internal.server.services.runner import client >>> s = client.ShimClient(port=10998) >>> s.submit("","", "ubuntu", None) ``` -------------------------------- ### Apply HTTP Server as a Service Source: https://github.com/dstackai/dstack/blob/master/examples/misc/http.server/README.md Use this command to run http.server as a service. Ensure the configuration file is correctly set up. ```shell dstack apply -f examples/misc/http.server/.dstack.yml ``` -------------------------------- ### Display dstack project add Help Source: https://github.com/dstackai/dstack/blob/master/docs/docs/reference/cli/dstack/project.md View the help information for the `dstack project add` command to understand its usage and options for adding new project configurations. ```shell $ dstack project add --help ``` -------------------------------- ### Get help for dstack apply command Source: https://github.com/dstackai/dstack/blob/master/skills/dstack/SKILL.md Use this command to get help specific to the `dstack apply` command for a given configuration type. ```bash dstack apply --help ``` -------------------------------- ### Install dstack server with Docker Source: https://github.com/dstackai/dstack/blob/master/docs/docs/installation.md Runs the dstack server using a Docker container, mapping the host's .dstack/server directory to the container. Requires Docker. ```shell $ docker run -p 3000:3000 \ -v $HOME/.dstack/server/:/root/.dstack/server \ dstackai/dstack Applying ~/.dstack/server/config.yml... The admin token is "bbae0f28-d3dd-4820-bf61-8f4bb40815da" The server is running at http://127.0.0.1:3000/ ``` -------------------------------- ### Install dstack in Activated Environment Source: https://github.com/dstackai/dstack/blob/master/contributing/DEVELOPMENT.md Alternatively, install dstack into an already activated virtual environment using uv sync with the --active flag. ```shell uv sync --all-extras --active ``` -------------------------------- ### Apply dstack configuration Source: https://github.com/dstackai/dstack/blob/master/examples/clusters/nccl-rccl-tests/README.md Use the `dstack apply` command to submit a dstack configuration file for execution. This example shows how to apply the NCCL tests configuration and interactively select a backend instance. ```shell $ dstack apply -f examples/clusters/nccl-rccl-tests/nccl-tests.dstack.yml # BACKEND REGION INSTANCE RESOURCES SPOT PRICE 1 aws us-east-1 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 2 aws us-west-2 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 3 aws us-east-2 g4dn.12xlarge 48xCPU, 192GB, 4xT4 (16GB), 100.0GB (disk) no $3.912 Submit the run nccl-tests? [y/n]: y ``` -------------------------------- ### Configure dstack CLI Source: https://github.com/dstackai/dstack/blob/master/docker/server/README.md Install the dstack CLI and configure it to connect to your dstack server. This involves specifying the server URL, user token, and project name. ```shell pip install dstack $dstack project add --name main \ --url http://127.0.0.1:3000 \ --token bbae0f28-d3dd-4820-bf61-8f4bb40815da ``` -------------------------------- ### Configure Development Environment with Local Repo Source: https://github.com/dstackai/dstack/blob/master/docs/blog/posts/0_20.md Set up a development environment using VS Code, cloning the repository from the parent directory into the working directory. This configuration ensures the repo is cloned locally and will fail if the repo directory is not empty. ```yaml type: dev-environment name: vscode repos: # Clones the repo from the parent directory (`examples/..`) to `` - .. ide: vscode ```