Skip to content

Commit

Permalink
NPU needs to be initialized when starting a new process (#2843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jq460494839 authored Dec 28, 2023
1 parent 3623d9b commit 1368f3f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fastchat/serve/model_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
str_to_torch_dtype,
)


worker_id = str(uuid.uuid4())[:8]
logger = build_logger("model_worker", f"model_worker_{worker_id}.log")

Expand Down Expand Up @@ -103,6 +102,10 @@ def __init__(
self.init_heart_beat()

def generate_stream_gate(self, params):
if self.device == "npu":
import torch_npu

torch_npu.npu.set_device("npu:0")
self.call_ct += 1

try:
Expand Down

0 comments on commit 1368f3f

Please sign in to comment.