Skip to content

Commit

Permalink
NPU needs to be initialized when starting a new process (lm-sys#2843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jq460494839 authored and zhanghao.smooth committed Jan 26, 2024
1 parent 4bc5d22 commit 3ce90e5
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 @@ -32,7 +32,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 @@ -104,6 +103,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 3ce90e5

Please sign in to comment.