forked from skypilot-org/skypilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ray_tune_app.py
36 lines (27 loc) · 993 Bytes
/
ray_tune_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from typing import List, Optional
import sky
with sky.Dag() as dag:
# Total Nodes, INCLUDING Head Node
num_nodes = 2
workdir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'ray_tune_examples')
# The setup command. Will be run under the working directory.
setup = 'pip3 install --upgrade pip && \
pip3 install ray[tune] pytorch-lightning==1.4.9 lightning-bolts torchvision'
# head_run = 'python3 tune_basic_example.py --smoke-test'
head_run = 'python3 tune_ptl_example.py'
# The command to run. Will be run under the working directory.
def run_fn(node_rank: int, ip_list: List[str]) -> Optional[str]:
return head_run if node_rank == 0 else None
train = sky.Task(
'train',
workdir=workdir,
setup=setup,
num_nodes=num_nodes,
run=run_fn,
)
train.set_resources({
sky.Resources(sky.AWS(), 'p3.2xlarge'),
})
sky.launch(dag)