@@ -21,8 +21,7 @@ Your folder can be a regular local folder or a Git repo.
21
21
22
22
=== "Dev environment"
23
23
24
- A dev environment lets you provision a remote machine with your code, dependencies, and resources, and access it
25
- with your desktop IDE.
24
+ A dev environment lets you provision an instance and access it with your desktop IDE.
26
25
27
26
##### Define a configuration
28
27
@@ -32,18 +31,14 @@ Your folder can be a regular local folder or a Git repo.
32
31
33
32
```yaml
34
33
type: dev-environment
35
- # The name is optional, if not specified, generated randomly
36
34
name: vscode
37
35
36
+ # If `image` is not specified, dstack uses its default image
38
37
python: "3.11"
39
- # Uncomment to use a custom Docker image
40
38
#image: dstackai/base:py3.13-0.6-cuda-12.1
41
39
42
40
ide: vscode
43
41
44
- # Use either spot or on-demand instances
45
- spot_policy: auto
46
-
47
42
# Uncomment to request resources
48
43
#resources:
49
44
# gpu: 24GB
@@ -78,24 +73,24 @@ Your folder can be a regular local folder or a Git repo.
78
73
79
74
Open the link to access the dev environment using your desktop IDE.
80
75
76
+ Alternatively, you can access it via `ssh <run name>`.
77
+
81
78
=== "Task"
82
79
83
- A task allows you to schedule a job or run a web app. It lets you configure
84
- dependencies, resources, ports, the number of nodes (if you want to run the task on a cluster), etc.
80
+ A task allows you to schedule a job or run a web app. Tasks can be distributed and can forward ports.
85
81
86
82
##### Define a configuration
87
83
88
84
Create the following configuration file inside the repo:
89
85
90
- <div editor-title="streamlit.dstack.yml">
86
+ <div editor-title="examples/misc/ streamlit/serve-task .dstack.yml">
91
87
92
88
```yaml
93
89
type: task
94
- # The name is optional, if not specified, generated randomly
95
90
name: streamlit
96
91
92
+ # If `image` is not specified, dstack uses its default image
97
93
python: "3.11"
98
- # Uncomment to use a custom Docker image
99
94
#image: dstackai/base:py3.13-0.6-cuda-12.1
100
95
101
96
# Commands of the task
@@ -106,16 +101,17 @@ Your folder can be a regular local folder or a Git repo.
106
101
ports:
107
102
- 8501
108
103
109
- # Use either spot or on-demand instances
110
- spot_policy: auto
111
-
112
104
# Uncomment to request resources
113
105
#resources:
114
106
# gpu: 24GB
115
107
```
116
108
117
109
</div>
118
110
111
+ By default, tasks run on a single instance. To run a distributed task, specify
112
+ [`nodes` and system environment variables](reference/dstack.yml/task.md#distributed-tasks),
113
+ and `dstack` will run it on a cluster.
114
+
119
115
##### Run the configuration
120
116
121
117
Run the configuration via [`dstack apply`](reference/cli/index.md#dstack-apply):
@@ -144,50 +140,41 @@ Your folder can be a regular local folder or a Git repo.
144
140
145
141
</div>
146
142
147
- `dstack apply` automatically forwards the remote ports to `localhost` for convenient access.
143
+ If you specified `ports`, they will be automatically forwarded to `localhost` for convenient access.
148
144
149
145
=== "Service"
150
146
151
- A service allows you to deploy a web app or a model as a scalable endpoint. It lets you configure
152
- dependencies, resources, authorization, auto-scaling rules, etc.
153
-
154
- ??? info "Prerequisites"
155
- If you're using the open-source server, you must set up a [gateway](concepts/gateways.md) before you can run a service.
156
-
157
- If you're using [dstack Sky :material-arrow-top-right-thin:{ .external }](https://sky.dstack.ai){:target="_blank"},
158
- the gateway is already set up for you.
147
+ A service allows you to deploy a model or any web app as an endpoint.
159
148
160
149
##### Define a configuration
161
150
162
151
Create the following configuration file inside the repo:
163
152
164
- <div editor-title="streamlit- service.dstack.yml">
153
+ <div editor-title="examples/deployment/vllm/ service.dstack.yml">
165
154
166
155
```yaml
167
156
type: service
168
- # The name is optional, if not specified, generated randomly
169
- name: streamlit-service
157
+ name: llama31-service
170
158
159
+ # If `image` is not specified, dstack uses its default image
171
160
python: "3.11"
172
- # Uncomment to use a custom Docker image
173
161
#image: dstackai/base:py3.13-0.6-cuda-12.1
174
162
175
- # Commands of the service
163
+ # Required environment variables
164
+ env:
165
+ - HF_TOKEN
176
166
commands:
177
- - pip install streamlit
178
- - streamlit hello
179
- # Port of the service
180
- port: 8501
181
-
182
- # Comment to enable authorization
183
- auth: False
167
+ - pip install vllm
168
+ - vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct --max-model-len 4096
169
+ # Expose the vllm server port
170
+ port: 8000
184
171
185
- # Use either spot or on-demand instances
186
- spot_policy: auto
172
+ # Specify a name if it's an Open-AI compatible model
173
+ model: meta-llama/Meta-Llama-3.1-8B-Instruct
187
174
188
- # Uncomment to request resources
189
- # resources:
190
- # gpu: 24GB
175
+ # Required resources
176
+ resources:
177
+ gpu: 24GB
191
178
```
192
179
193
180
</div>
@@ -213,28 +200,32 @@ Your folder can be a regular local folder or a Git repo.
213
200
Provisioning `streamlit`...
214
201
---> 100%
215
202
216
- Welcome to Streamlit. Check out our demo in your browser.
217
-
218
- Local URL: https://streamlit-service.example.com
203
+ Service is published at:
204
+ http://localhost:3000/proxy/services/main/llama31-service
219
205
```
220
206
221
207
</div>
222
208
223
- Once the service is up, its endpoint is accessible at `https://<run name>.<gateway domain>`.
209
+ If you specified `model`, the model will also be available via an OpenAI-compatible endpoint at
210
+ `<dstack server URL>/proxy/models/<project name>`.
211
+
212
+ ??? info "Gateway"
213
+ By default, services run on a single instance. However, you can specify `replicas` and `target` to enable
214
+ [auto-scaling](reference/dstack.yml/service.md#auto-scaling).
224
215
225
- > ` dstack apply ` automatically uploads the code from the current repo, including your local uncommitted changes.
216
+ Note, to use auto-scaling, a custom domain, or HTTPS, set up a
217
+ [gateway](concepts/gateways.md) before running the service.
218
+ A gateway pre-configured for you if you are using [dstack Sky :material-arrow-top-right-thin:{ .external }](https://sky.dstack.ai){:target="_blank"}.
219
+
220
+ ` dstack apply ` automatically provisions instances, uploads the code from the current repo (incl. your local uncommitted changes).
226
221
227
222
## Troubleshooting
228
223
229
- Something not working? Make sure to check out the [ troubleshooting] ( guides/troubleshooting.md ) guide.
224
+ Something not working? See the [ troubleshooting] ( guides/troubleshooting.md ) guide.
230
225
231
226
## What's next?
232
227
233
228
1 . Read about [ dev environments] ( dev-environments.md ) , [ tasks] ( tasks.md ) ,
234
229
[ services] ( services.md ) , and [ fleets] ( concepts/fleets.md )
235
- 2 . Browse [ examples] ( https://dstack.ai/examples )
236
- 3 . Join the community via [ Discord :material-arrow-top-right-thin:{ .external }] ( https://discord.gg/u8SmfwPpMd )
237
-
238
- !!! info "Examples"
239
- To see how dev environments, tasks, services, and fleets can be used for
240
- training and deploying AI models, check out the [ examples] ( examples/index.md ) .
230
+ 2 . Join [ Discord :material-arrow-top-right-thin:{ .external }] ( https://discord.gg/u8SmfwPpMd )
231
+ 3 . Browse [ examples] ( https://dstack.ai/examples )
0 commit comments