-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_ray_cache.py
More file actions
40 lines (31 loc) · 1.16 KB
/
run_ray_cache.py
File metadata and controls
40 lines (31 loc) · 1.16 KB
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
37
38
39
40
import ray
from app.ray.cache import Cache
from app.ray.semaphore import SemaphoreActor
from app.ray.utils import parse_cache_worker_args
from app.sentry import sentry_sdk
def main(name, num_cpus, num_gpus, namespace):
# Initialize Ray
ray.init(ignore_reinit_error=True, namespace=namespace)
bluesky_semaphore = SemaphoreActor.options(
name="semaphore:bluesky", lifetime="detached"
).remote()
graze_semaphore = SemaphoreActor.options(
name="semaphore:graze", lifetime="detached"
).remote(10)
# Start the Cache actor with the specified resources and name
cache_actor = Cache.options(
name=name, lifetime="detached", num_cpus=num_cpus, num_gpus=num_gpus
).remote()
print(
f"Cache worker '{name}' started with {num_cpus} CPUs and {num_gpus} GPUs and running..."
)
# Keep the script running to maintain the actor
try:
import time
while True:
time.sleep(10)
except KeyboardInterrupt:
print(f"Cache worker '{name}' stopped.")
if __name__ == "__main__":
args = parse_cache_worker_args()
main(args.name, args.num_cpus, args.num_gpus, args.namespace)