[论文笔记] 大模型gpu机器推理测速踩坑 (llama/gpt类)

[论文笔记] 大模型gpu机器推理测速踩坑 (llama/gpt类)

    正在检查是否收录...
一言准备中...

cpu没报错,换gpu就报错。以下是一些踩坑:

坑1:要指定gpu,可以在import torch之前指定gpu。

model = LlamaForCausalLM.from_pretrained(model_path, trust_remote_code=True).to(device)

报错: RuntimeError('Expected all tensors to be on the same device, but found at least two devices, cuda:6 and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)')

坑2:model和input_ids都需要 .to(device),tokenizer不需要。

坑3:不要用device_map="auto",不然变量不在一张卡上。就算model和输入都to(device)了,也会报错。

报错:You can't move a model that has some modules offloaded to cpu or disk.

可以检查参数都在哪个卡,cpu/gpu。但是这样其实检查不出来啥:

坑4:custom_llama不能用AutoModelForCausalLM,要用LlamaForCausalLM。

gpullmllamacodecpuapptokenrapurl
  • 本文作者:WAP站长网
  • 本文链接: https://wapzz.net/post-4876.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.7W+
9
1
2
WAP站长官方

解决JetBrains IDE中使用GitHub Copilot报错(code:-32603)问题(已挂代理)

上一篇

腾讯云 Serverless Stable Diffusion 应用免费名额限量放送,试用申请开启!

下一篇
  • 复制图片
按住ctrl可打开默认菜单