在jupyter notebook中调用通义千问大模型,test时遇到报错 RuntimeError: "addmm_impl_cpu_" not implement。
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
query = "内容"
local_model_path = r"./Qwen-1-8B-Chat"
tokenizer = AutoTokenizer.from_pretrained(local_model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(local_model_path, device_map="auto", trust_remote_code=True).eval()
response, history = model.chat(tokenizer, query, history=None)
print("回答如下:\n", response)
RuntimeError: "addmm_impl_cpu_" not implemented for 'Half'
这个错误通常是因为在代码中没有正确地初始化线程对象导致的。
解决方法:重启内核,实现初始化线程对象即可。