网站建设使用工具,贸易公司 网站 扶持,福州在线项目建设管理系统,免费网站建设推广服务微调chatglm 报错RuntimeError: expected scalar type Half but found Float
1. 背景
博主显卡#xff1a;3090 最初的设置#xff1a;bfloat16 开始训练后#xff0c;线性层报错
2. 解决: 统一代码中所有精度
1#xff09;将模型和数据精度都设置为torch.float32/torc…微调chatglm 报错RuntimeError: expected scalar type Half but found Float
1. 背景
博主显卡3090 最初的设置bfloat16 开始训练后线性层报错
2. 解决: 统一代码中所有精度
1将模型和数据精度都设置为torch.float32/torch.float16
xxx torch.tensor(xxx, dtypetorch.float32)
model.config.torch_dtype torch.float322将模型参数都设置为torch.float32/torch.float16
for param in model.parameters():# Check if parameter dtype is Float (float32)if param.dtype torch.float16:param.data param.data.to(torch.float32)