-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.py
More file actions
25 lines (19 loc) · 756 Bytes
/
train.py
File metadata and controls
25 lines (19 loc) · 756 Bytes
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
import subprocess
import time
from master import detect_workers
from model import split_model, load_user_model
# Number of required workers
required_workers = 3 # Change this if needed
# Detect currently running workers
existing_worker_ports = detect_workers()
# Start missing workers
new_worker_ports = [5001 + i for i in range(required_workers) if (5001 + i) not in existing_worker_ports]
for port in new_worker_ports:
print(f"🚀 Starting worker on port {port}...")
subprocess.Popen(["python", "worker.py", str(port)])
time.sleep(2) # Give some time for workers to start
# Wait a few seconds to let workers initialize
time.sleep(5)
# Start master node
print("🚀 Starting master node...")
subprocess.Popen(["python", "master.py"])