File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 13
13
- Type "!!save <filename>" to save the conversation history to a json file.
14
14
- Type "!!load <filename>" to load a conversation history from a json file.
15
15
"""
16
+
16
17
import argparse
17
18
import os
18
19
import re
@@ -197,6 +198,14 @@ def main(args):
197
198
)
198
199
os .environ ["CUDA_VISIBLE_DEVICES" ] = args .gpus
199
200
os .environ ["XPU_VISIBLE_DEVICES" ] = args .gpus
201
+ if len (args .gpus .split ("," )) == 1 :
202
+ try :
203
+ import torch_npu
204
+
205
+ torch .npu .set_device (int (args .gpus ))
206
+ print (f"NPU is available, now model is running on npu:{ args .gpus } " )
207
+ except ModuleNotFoundError :
208
+ pass
200
209
if args .enable_exllama :
201
210
exllama_config = ExllamaConfig (
202
211
max_seq_len = args .exllama_max_seq_len ,
Original file line number Diff line number Diff line change 1
1
"""
2
2
A model worker that executes the model.
3
3
"""
4
+
4
5
import argparse
5
6
import base64
6
7
import gc
@@ -351,6 +352,14 @@ def create_model_worker():
351
352
f"Larger --num-gpus ({ args .num_gpus } ) than --gpus { args .gpus } !"
352
353
)
353
354
os .environ ["CUDA_VISIBLE_DEVICES" ] = args .gpus
355
+ if len (args .gpus .split ("," )) == 1 :
356
+ try :
357
+ import torch_npu
358
+
359
+ torch .npu .set_device (int (args .gpus ))
360
+ print (f"NPU is available, now model is running on npu:{ args .gpus } " )
361
+ except ModuleNotFoundError :
362
+ pass
354
363
355
364
gptq_config = GptqConfig (
356
365
ckpt = args .gptq_ckpt or args .model_path ,
Original file line number Diff line number Diff line change 11
11
We recommend using this with multiple Peft models (with `peft` in the name)
12
12
where all Peft models are trained on the exact same base model.
13
13
"""
14
+
14
15
import argparse
15
16
import asyncio
16
17
import dataclasses
@@ -206,6 +207,14 @@ def create_multi_model_worker():
206
207
f"Larger --num-gpus ({ args .num_gpus } ) than --gpus { args .gpus } !"
207
208
)
208
209
os .environ ["CUDA_VISIBLE_DEVICES" ] = args .gpus
210
+ if len (args .gpus .split ("," )) == 1 :
211
+ try :
212
+ import torch_npu
213
+
214
+ torch .npu .set_device (int (args .gpus ))
215
+ print (f"NPU is available, now model is running on npu:{ args .gpus } " )
216
+ except ModuleNotFoundError :
217
+ pass
209
218
210
219
gptq_config = GptqConfig (
211
220
ckpt = args .gptq_ckpt or args .model_path ,
You can’t perform that action at this time.
0 commit comments