xiaoxishui commited on
Commit
cd93ee6
·
1 Parent(s): 1559fe0

Update app.py: Add device=device

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -186,12 +186,14 @@ def on_btn_click():
186
 
187
  @st.cache_resource
188
  def load_model():
189
- model = (AutoModelForCausalLM.from_pretrained(
190
  model_name_or_path,
191
  trust_remote_code=True,
192
  use_cache=False, # 禁用 KV 缓存
193
  torch_dtype=torch.bfloat16,
194
- device_map="auto")).cuda()
 
 
195
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path,
196
  trust_remote_code=True)
197
  return model, tokenizer
@@ -279,7 +281,7 @@ def main():
279
  tokenizer=tokenizer,
280
  prompt=real_prompt,
281
  additional_eos_token_id=92542,
282
- device='cuda:0',
283
  **asdict(generation_config),
284
  ):
285
  # Display robot response in chat message container
 
186
 
187
  @st.cache_resource
188
  def load_model():
189
+ model = AutoModelForCausalLM.from_pretrained(
190
  model_name_or_path,
191
  trust_remote_code=True,
192
  use_cache=False, # 禁用 KV 缓存
193
  torch_dtype=torch.bfloat16,
194
+ device_map="auto",
195
+ low_cpu_mem_usage=True
196
+ )
197
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path,
198
  trust_remote_code=True)
199
  return model, tokenizer
 
281
  tokenizer=tokenizer,
282
  prompt=real_prompt,
283
  additional_eos_token_id=92542,
284
+ device=device,
285
  **asdict(generation_config),
286
  ):
287
  # Display robot response in chat message container