ChatGLM多卡微调踩坑记录

题主近期尝试使用LoRA在自有数据上微调ChatGLM,尽管GitHub上已有很多LoRA相关代码,但实现过程中题主还是遇到了很多问题,现将遇到的问题整理出来供大家参考,实现的相关代码也会整理到GitHub.

1. Error: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0!

使用deepspeed多卡训练时会遇到这个问题,原因是由于ChatGLM进行了一次更新,使用离线下载的老版模型参数和AutoModel加载的新版配置会发生冲突。

可以通过模型中的config.json文件鉴别下载到本地的ChatGLM是老版还是新版。

老版的ChatGLM的vocab_size为150528:

{
  "_name_or_path": "THUDM/chatglm-6b",
  "architectures": [
    "ChatGLMModel"
  ],
  "auto_map": {
    "AutoConfig": "configuration_chatglm.ChatGLMConfig",
    "AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
    "AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
  },
  "bos_token_id": 150004,
  "eos_token_id": 150005,
  "pad_token_id": 20003,
  "hidden_size": 4096,
  &

猜你喜欢

转载自blog.csdn.net/u013250861/article/details/131262206