-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the
Leveraging spot instances effectively
guide to /learn
- Added a usage example to `/docs/reference/api/python/index.md` - Updated some URLs within `learn` (to make them unified and short)
- Loading branch information
1 parent
c4a32e3
commit 9bb8e21
Showing
16 changed files
with
181 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Leveraging spot instances effectively | ||
|
||
Cloud instances come in three types: `reserved` (for long-term commitments at a cheaper rate), `on-demand` (used as needed but | ||
more expensive), and `spot` (cheapest, provided when available, but can be taken away when requested by someone else). | ||
|
||
There are three cloud providers that offer spot instances: AWS, GCP, and Azure. | ||
Once you've [configured](../docs/config/server.md) any of these, you can use spot instances | ||
for [dev environments](../docs/guides/dev-environments.md), [tasks](../docs/guides/tasks.md), and | ||
[services](../docs/guides/services.md). | ||
|
||
!!! info "Quotas" | ||
Note, before you can use spot instances with AWS, GCP, and Azure, ensure you request the necessary quota via a support | ||
ticket. | ||
|
||
## Setting a spot policy | ||
|
||
For dev environments, `dstack` uses on-demand instances by default. For | ||
tasks and services, `dstack` tries to use spot instances if they are available, falling back to on-demand instances. | ||
|
||
The `dstack run` command allows you to override the default behavior. | ||
To use `spot` instances, pass `--spot`. To use `spot` instances only they are available, | ||
pass `--spot-auto`. | ||
|
||
<div class="termy"> | ||
|
||
```shell | ||
$ dstack run . --gpu 24GB --spot-auto | ||
Max price - | ||
Max duration 6h | ||
Spot policy auto | ||
Retry policy no | ||
|
||
# BACKEND REGION RESOURCES SPOT PRICE | ||
1 gcp us-central1 4xCPU, 16GB, L4 (24GB) yes $0.223804 | ||
2 gcp us-east1 4xCPU, 16GB, L4 (24GB) yes $0.223804 | ||
3 gcp us-west1 4xCPU, 16GB, L4 (24GB) yes $0.223804 | ||
... | ||
|
||
Continue? [y/n]: | ||
``` | ||
|
||
</div> | ||
|
||
## Setting a retry policy | ||
|
||
If the requested instance is unavailable, the `dstack run` command will fail unless you specify a retry policy. | ||
The policy can be specified via `--retry-limit`: | ||
|
||
<div class="termy"> | ||
|
||
```shell | ||
$ dstack run . --gpu 24GB --spot --retry-limit 1h | ||
``` | ||
|
||
</div> | ||
|
||
In this case, `dstack` will retry to find spot instances within one hour. | ||
|
||
!!! info "NOTE:" | ||
Note that if you've set the retry duration and the spot instance is taken while your run was not | ||
finished, `dstack` will restart it from scratch. | ||
|
||
If you run a service using spot instances, the default retry duration is set to infinity. | ||
|
||
## Tips and tricks | ||
|
||
1. The `--spot-auto` policy allows for the automatic use of spot instances when available, seamlessly reverting to | ||
on-demand instances if spots aren't accessible. You can enable it via `dstack run` or | ||
via [`profiles.yml`](../docs/reference/profiles.yml.md). | ||
2. You can use multiple cloud providers (incl. AWS, GCP, and Azure) and regions to increase the likelihood of | ||
obtaining a spot instance. However, in doing so, beware of data transfer costs if large volumes of data | ||
need to be loaded. | ||
3. When using spot instances for training, ensure you save checkpoints regularly and load them if the run is restarted | ||
due to interruption. | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.