Comments (1)
i can only use gpu,and ran the code below
import torch from transformers import AutoTokenizer, AutoModel from modeling_chatglm import ChatGLMForConditionalGeneration
tokenizer = AutoTokenizer.from_pretrained( "./model", trust_remote_code=True)
model = ChatGLMForConditionalGeneration.from_pretrained( "./model").half()
while True: a = input("请输入您的问题:(输入q以退出)") if a.strip() == 'q':
exit() response, history = model.chat(tokenizer, "问题:" + a.strip() + '\n答案:', max_length=256, history=[]) print("回答:", response)
errors:RuntimeError: "LayerNormKernelImpl" not implemented for 'Half',however i use model = ChatGLMForConditionalGeneration.from_pretrained( "./model",torch_type=torch.float32),error "RuntimeError: mixed dtype (CPU): expect parameter to have scalar type of bFloat " if i use ChatGLMForConditionalGeneration.from_pretrained( "./model",torch_type=torch.Bfloat) errors"RuntimeError: mixed dtype (CPU): expect parameter to have scalar type of Float" how can i run the code correctly?
What a coincidence! I encoutered the same problem as you. I found a Blog that might be useful to you.
To summary, the reason for this problem should be that the model is not placed on the GPU. Because the model needs to be half()
and CPU can't do it, only GPU can.
So you can try to add .cuda()
, as shown below
model = ChatGLMForConditionalGeneration.from_pretrained(
"./model").half().cuda()
from med-chatglm.
Related Issues (20)
- 全部的数据集可以开源吗 HOT 1
- 微调自己数据集遇到账户之类的错误问题,请问怎么解决,实在不理解报错 HOT 2
- 这个项目微调的时候可以设quantization_bit么?在sf_medchat.sh里怎么设?
- modeling_chatglm.py里的quantize能用么?在run_clm.py里添加model.quantize(4)为什么报ImportError: attempted relative import with no known parent package错误
- 项目如何改成cpu微调的,可不可以把用内存,不用显存 HOT 1
- 6G显存问题和模型参数本地目录指向问题 HOT 1
- 把chatglm-6b-med模型放到官方chatglm-6b中训练报错 HOT 1
- ”医学知识库和数据集构建代码还在整理中,整理完成将会发布。“ HOT 3
- 报错150004 is not in list,请问如何进一步修改?谢谢 HOT 3
- 显示不出答案
- 请问如何将知识图谱批量地转为问答对
- Out of memory. 48G is not enough, either. What happend? HOT 1
- 问题
- 是否支持使用多机多卡进行微调?
- chatGLM2微调问题 HOT 1
- 希望取得联系
- 运行报错 HOT 4
- 批量喂数据给模型
- 是否有定义评价指标
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from med-chatglm.