Initialize worker process, set GPU environment, and initialize the model
(model_path, gpu_id)
| 12 | from pathlib import Path |
| 13 | import jsonlines |
| 14 | def init_worker(model_path, gpu_id): |
| 15 | """Initialize worker process, set GPU environment, and initialize the model""" |
| 16 | os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id) |
| 17 | print(f"Process {os.getpid()} using GPU {gpu_id}") |
| 18 | |
| 19 | global model |
| 20 | model = LLM( |
| 21 | model=model_path, |
| 22 | max_num_batched_tokens=8192, |
| 23 | max_model_len=8192, |
| 24 | seed=1, |
| 25 | trust_remote_code=True, |
| 26 | tensor_parallel_size=1 |
| 27 | ) |
| 28 | |
| 29 | def process_single_item(item, sampling_params, num_batches): |
| 30 | """Process a single data item""" |
nothing calls this directly
no outgoing calls
no test coverage detected