OpenBMB / MiniCPM-V

MiniCPM-Llama3-V 2.5: A GPT-4V Level Multimodal LLM on Your Phone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] 如何合并lora后的权重

Gary2018X opened this issue · comments

commented

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

  • 我已经搜索过已有的issues和讨论 | I have searched the existing issues / discussions

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

  • 我已经搜索过FAQ | I have searched FAQ

当前行为 | Current Behavior

No response

期望行为 | Expected Behavior

No response

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA (`python -c 'import torch; print(torch.version.cuda)'`):

备注 | Anything else?

No response

commented

然后可以通过model.merge_and_unload()合并吗

我有点不清楚你说的合并是什么意思,我们提供的方式应该可以正常的加载模型

commented

就是把lora权重和基础模型合并到一个模型

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错:
Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的
tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)
deepspeed降到0.14.0之后,问题还存在
我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

@todaydeath 了解了,那就不清楚了,我目前还没有涉及到这些方面

image
比较好奇的是,如果是默认多卡运行的,这个更新是为了解决什么问题呢

@todaydeath 了解了,那就不清楚了,我目前还没有涉及到这些方面

后续如果我有进展的话会再告知你

@todaydeath 了解了,那就不清楚了,我目前还没有涉及到这些方面

后续如果我有进展的话会再告知你

好的,多谢

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

我这边遇到了同样的问题,deepspeed降到0.14.0之后问题也没有解决(降后重新做LoRA也是报同样的错)。请问这里现在有解决方式吗?

File "*******/minicpm-eval-lora.py", line 57, in
response = model.chat(
File "/root/.cache/huggingface/modules/transformers_modules/MiniCPM-Llama3-V-2_5/modeling_minicpmv.py", line 454, in chat
res, vision_hidden_states = self.generate(
File "/root/.cache/huggingface/modules/transformers_modules/MiniCPM-Llama3-V-2_5/modeling_minicpmv.py", line 354, in generate
) = self.get_vllm_embedding(model_inputs)
File "/root/.cache/huggingface/modules/transformers_modules/MiniCPM-Llama3-V-2_5/modeling_minicpmv.py", line 156, in get_vllm_embedding
cur_vllm_emb.scatter_(0, image_indices.view(-1, 1).repeat(1, cur_vllm_emb.shape[-1]),
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

这里的链接貌似已经失效了,我这边遇到了跟您一样的问题,单张卡(device_map = 'cuda')会OOM,多张卡(devive_map = 'auto')会报tensors to be on the same device, but found at least two devices。请问可否指导下问题是怎么解决的吗?
我这边的环境是两张V100。deepspeed版本从0.14.2降成0.14.0也无济于事。

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

@todaydeath 您好,链接里面没有“模型合并”的脚本,分享的链接好像都一点不相关,可以分享模型合并脚本吗?谢谢!

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

@todaydeath 您好,链接里面没有“模型合并”的脚本,分享的链接好像都一点不相关,可以分享模型合并脚本吗?谢谢!

不好意思,发错链接了。正确: https://www.chenxublog.com/2024/04/23/single-card-fine-tuning-minicpm-merging-lora-and-converting-to-gguf-for-llama-cpp.html
image

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

@todaydeath 您好,链接里面没有“模型合并”的脚本,分享的链接好像都一点不相关,可以分享模型合并脚本吗?谢谢!

不好意思,发错链接了。正确: https://www.chenxublog.com/2024/04/23/single-card-fine-tuning-minicpm-merging-lora-and-converting-to-gguf-for-llama-cpp.html image

你好,我在尝试合并模型时merge_and_unload(),遇到如下报错RuntimeError: The weights trying to be saved contained shared tensors [{'llm.model.embed_tokens.weight', 'llm.embed_tokens.weight'}] that are mismatching the transformers base configuration. Try saving using safe_serialization=False or remove this tensor sharing. 请问您了解为什么吗

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 这个多卡运行不了,报错: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src)

你可以检查一下deepspeed版本,这个可能是因为deepspeed版本导致的,降级到0.14.0可以解决

deepspeed降到0.14.0之后,问题还存在。这个默认是支持多卡运行的么?

降级后问题不存在了,默认是多卡运行的,这个是deepspeed的bug,具体你可以看这里 microsoft/DeepSpeed#5422

你给的这个链接报错信息是数据在gpu和cpu之间的报错,我这里的报错是在两块显卡之间的 tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6! (when checking argument for argument src in method wrapper_CUDA_scatter__src) deepspeed降到0.14.0之后,问题还存在 我这里的显卡型号是3090,应该是不支持显卡间通信,有可能是这个原因么

应该不是,没有查到3090不支持显卡间通信的资料,如果你能查到相关信息的话,也欢迎分享一下;你可以放一下训练的脚本和相关的环境配置吗,看一下是否是哪里设置有问题

这个问题在使用web_demo_2.5.py的时候就有的。web_demo_2.5.py里面device默认是cuda,启动的时候使用的是cuda:0,当把device类型改为auto(和https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 中的device类型一致)之后,可以运行起来,但是在进行对话时也是会报tensors to be on the same device, but found at least two devices, cuda:0 and cuda:6(也可能是其他显卡,例如cuda:5)的错。

当前找到了一个解决方案,是使用https://community.openai.com/t/how-to-do-few-shot-prompting-interweaving-text-and-images-with-gpt-4-vision-preview-as-seen-in-the-dawn-of-lmms-preliminary-explorations-with-gpt-4v-ision/598794/2 里面的脚本做了模型合并,然后根据https://github.com/OpenBMB/MiniCPM-V/blob/main/docs/inference_on_multiple_gpus.md做的GPU串行推理

@todaydeath 您好,链接里面没有“模型合并”的脚本,分享的链接好像都一点不相关,可以分享模型合并脚本吗?谢谢!

不好意思,发错链接了。正确: https://www.chenxublog.com/2024/04/23/single-card-fine-tuning-minicpm-merging-lora-and-converting-to-gguf-for-llama-cpp.html image

你好,我在尝试合并模型时merge_and_unload(),遇到如下报错RuntimeError: The weights trying to be saved contained shared tensors [{'llm.model.embed_tokens.weight', 'llm.embed_tokens.weight'}] that are mismatching the transformers base configuration. Try saving using safe_serialization=False or remove this tensor sharing. 请问您了解为什么吗

不清楚,这个问题我没遇到