| name | dstack-dev |
|---|---|
| description | dstack is an open-source control plane for GPU provisioning and orchestration across GPU clouds, Kubernetes, and on-prem clusters. This skill is specifically designed for using dstack's dev environments when it's required to experiment with code, tune and debug workloads before running them as tasks or services. It covers best practices for configuring dev environments, connecting to them via SSH to run commands interactively, e.g. to experiment and debug code. For example, this skill is ideal to test various configurations and find optimal commands and parameters to use with a specific framework on specific hardware. |
Below is a brief playbook for using dev environments when you need to tune and debug your code before running it on a specific hardware as a task or service.
dstackskill: Use thedstackskill that covers core capabilities ofdstackfor managing fleets, tasks, and services. This includes best practices for applying configurations, monitoring workloads, and troubleshooting common issues.- Fleet: Select an instance configuration that matches the hardware requirements you need to run the workload. This primarily includes the number of GPUs, the GPU name, and the minimum size of the disk (e.g. enough to store model weights). You can use
dstack offerCLI command to see all available offers across the backends configured for the project. Once you know which instance configuration you want to use, ensure there is a matching fleet. Create a fleet if needed.dstacksupports two types of backends: VM-based and container-based. The primary difference is that VM-based backends allow pre-provisioned instances (allowing you to setnodesto greater than0); this allows re-using instances across runs. Container backends provision instances on-demand (requiring you to setnodesto a range, e.g.0..<number>) and delete them once the run is complete. SSH fleets work similarly to VM-based fleets, but they allow you to run workloads on on-prem instances. When it's possible, it's recommended to use VM-based fleets since you can pre-provision instances and re-use them across runs. This is especially useful if you want to try different Docker images. But the final choice depends on your use case and requirements. - Docker image: Select a Docker image that is most recommended for your workload (including the GPU model, the framework, etc.). The Docker image must match what you later plan to use with tasks or services once you finish development. If the workload downloads models, kernels, or framework artifacts, consider mounting an optional instance volume at
/root/.cache. In some special cases, when it's critically important to test multiple Docker images from the same run, with VM-based fleets, it's possible to setdocker: trueon a run configuration instead of settingimage. This allows you to usedocker rundirectly inside your run and try multiple images without needing to re-submit your run. The downside of it is manual invocation ofdocker runand the need to use a VM-based backend or SSH fleet that may not always be available. - Dev environment: Once there is a matching fleet, and you decided on the Docker image (or to use
docker run), create a dev environment configuration, and specify a fleet that you intend to use. Invokedstack applyCLI command on this configuration. Follow thedstackskill guidance on how to apply configuration and troubleshoot common issues. For example, it's recommended to run it in the detached mode (by passing-d). - SSH: After the run status changes to
running, usedstack attach <run name> --logsCLI command to configure SSH access inside the run. Once the command is successful, you can usessh <run name>to connect inside the dev environment, and invoke commands. Run commands to experiment with your code, tune parameters, and debug issues. Once you confirm that commands are fully tested and tuned, you can use the same commands for a task or service configuration. IMPORTANT: bothdstack attachandsshcommands require full-access and must run outside of the sandbox. If you run them inside the sandbox, they will fail. - Iterate: If you are not using
docker: true, to try another Docker image, you can stop the run, change the image in the dev environment configuration, and run it again. The same applies to a fleet configuration. If you decide to try different hardware, you can consider creating another fleet or updating the existing one (would require instances to stop first if it's a container-based fleet).
To summarize, below is the recommended workflow for using dev environments for tuning and debugging code:
Just as an example, let's say you want to find the right hardware and parameters to deploy a model using a specific framework and ensure it works.
- Make sure you get a good understanding of what framework you plan to use, what GPUs and what disk space will be required given the model and its variant you want to deploy. Check the framework or model's official docs, cookbook, or model card for the initial baseline.
- Use
dstack offerto find the right instance configuration that matches your requirements. Ensure there is a matching fleet, and create one if needed. - Select a Docker image that is most recommended for your use case. If the workload downloads models, kernels, or framework artifacts, consider an optional
/root/.cacheinstance volume. If you want to try multiple images, consider usingdocker: trueoption (requires a VM-based backend). - Create a dev environment configuration, and apply it.
- Once the run is
running, usedstack attachto configure SSH access. - Use
sshto connect to the dev environment and run commands to experiment, tune, and debug your code. - Once you are happy with the results, use the same hardware and commands to create a task or service configuration and run it.
- If you want to try different hardware or Docker images, iterate by updating the fleet or dev environment configuration and re-applying it.
- Make sure to run
dstack attachandsshcommands outside of the sandbox, otherwise they will fail. - Enable
dstackskill before using the above workflow.