-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker_thread.py
More file actions
48 lines (39 loc) · 1.62 KB
/
Copy pathworker_thread.py
File metadata and controls
48 lines (39 loc) · 1.62 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
41
42
43
44
45
46
47
from worker_thread import WorkerThread
import logging
import secrets
import sys
import os
from docker.types import DeviceRequest
class llm_worker(WorkerThread):
def __init__(self, influxdb_client, docker_client, process_config):
super().__init__(influxdb_client, docker_client, process_config)
self.access_token = secrets.token_urlsafe(32)
def start(self):
results_dir = self.config.process_config.get("results_dir", None)
if not results_dir:
logging.critical("Failed to start llm_worker: required field results_dir is missing")
sys.exit(1)
self.config.image_name = "ghcr.io/oran-testing/llm_worker"
self.cleanup_old_containers()
self.config.container_env = {
"CONFIG": self.config.config_file,
"RESULTS_DIR": results_dir,
"NVIDIA_VISIBLE_DEVICES": "all",
"NVIDIA_DRIVER_CAPABILITIES": "all"
}
self.setup_env()
self.setup_networks()
self.config.container_volumes[self.config.config_file] = {"bind": "/llm.yaml", "mode": "ro"}
self.config.container_volumes[f"{os.getenv('DOCKER_SYSTEM_DIRECTORY')}/.llm_worker_cache"] = {"bind": "/app/huggingface_cache", "mode": "rw"}
self.config.container_volumes["/tmp/.rt_results"] = {"bind": "/host/logs/", "mode": "rw"}
self.setup_volumes()
self.config.device_requests.append(
DeviceRequest(
count=-1,
capabilities=[["gpu"]],
driver="nvidia"
)
)
self.start_container()
def get_token(self):
return self.access_token