RuntimeError: probability tensor contains either `inf`, `nan` or element < 0
dayL-W opened this issue · comments
是否已有关于该错误的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
使用V100的显卡,模型是INT4的,调用方式是魔搭写的demo,重要的包版本如下:
transformers 4.37.1
modelscope 1.13.3
推理的时候报这个错误
RuntimeError: probability tensor contains either inf
, nan
or element < 0
应该很多人都会有这个问题吧,我看历史的issue也没有解决
期望行为 | 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
请问这个问题解决了吗?
我也遇到了这个问题,你可以看下你训练过程中是不是loss降为0了,如果是这样说明训练的有问题,导致模型推理时乱输出,我解决了loss为0的问题后没有遇到当前这个问题了,解决loss为0的方法是从v100更换到A100,原理个人猜测是V100不支持bf16,所以能支持bf16的应该都行
有人解决吗,我也遇到了这个问题,t4卡单卡报Cannot copy out of meta tensor; no data!多卡报probability tensor contains either inf
, nan
or element < 0
+1, 用的是qw7,lora微调,v100 32g
+1, 用的是qw7,lora微调,v100 32g
v100不行,因为不支持bf16,我换过A100,A800,H800就都可以,因为这三个都支持
+1, 用的是qw7,lora微调,v100 32g
v100不行,因为不支持bf16,我换过A100,A800,H800就都可以,因为这三个都支持
多谢回答,那就是用 AutoModelForCausalLM.from_pretrained加载模型的时候改成fp16?我之前没设置过参数,“[RuntimeError: probability tensor contains either inf, nan or element < 0]”这个也是有时候有
+1, 用的是qw7,lora微调,v100 32g
v100不行,因为不支持bf16,我换过A100,A800,H800就都可以,因为这三个都支持
多谢回答,那就是用 AutoModelForCausalLM.from_pretrained加载模型的时候改成fp16?我之前没设置过参数,“[RuntimeError: probability tensor contains either inf, nan or element < 0]”这个也是有时候有
你可以看下你训练过程中是不是loss降为0了,如果是这样说明训练的有问题,导致模型推理时乱输出,我解决了loss为0的问题后没有遇到当前这个问题了,解决loss为0的方法是从v100更换到A100或者H800,所以还是换卡才完全避免了这些问题的
@aixiaoing 您好,我这边用bf16训练,训练一会后会出现loss=0,请问有什么解决方法吗